gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/mailbox.hbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      mailbox.h
   16:  *      Mailbox
   17:  */
   18: 
   19: #ifndef _MAILBOX_H_
   20: #define _MAILBOX_H_
   21: /*
   22:  * Mailbox control block
   23:  *
   24:  *      'mq_head' is the first message queue pointer that
   25:  *      points a message.
   26:  *      It is NULL if the message queue is empty.
   27:  *      'mq_tail' is a pointer that points end of message
   28:  *      queue that is not empty.
   29:  *      The message queue value is not guaranteed if the
   30:  *      message queue is empty.
   31:  *      It is used only if the message queue is FIFO (TA_MFIFO).
   32:  */
   33: typedef struct mailbox_control_block {
   34:         QUEUE  wait_queue;      /* Mailbox wait queue */
   35:         ID     mbxid;              /* Mailbox ID */
   36:         void   *exinf;           /* Extended information */
   37:         ATR    mbxatr;            /* Mailbox attribute */
   38:         T_MSG  mq_head; /* Head of message queue */
   39:         T_MSG  *mq_tail;        /* End of message queue */
   40: #if USE_OBJECT_NAME
   41:         UB     name[OBJECT_NAME_LENGTH];   /* name */
   42: #endif
   43: } MBXCB;
   44: 
   45: IMPORT MBXCB knl_mbxcb_table[]; /* Mailbox control block */
   46: IMPORT QUEUE knl_free_mbxcb;    /* FreeQue */
   47: 
   48: #define get_mbxcb(id)   ( &knl_mbxcb_table[INDEX_MBX(id)] )
   49: 
   50: /*
   51:  * Head message
   52:  */
   53: #define headmsg(mbxcb)  ( (mbxcb)->mq_head.msgque[0] )
   54: 
   55: /*
   56:  * Next message
   57:  */
   58: #define nextmsg(msg)    ( ((T_MSG*)(msg))->msgque[0] )
   59: 
   60: /*
   61:  * Insert a message queue following priority
   62:  */
   63: Inline void knl_queue_insert_mpri( T_MSG_PRI *pk_msg, T_MSG *head )
   64: {
   65:         T_MSG_PRI      *msg;
   66:         T_MSG          *prevmsg = head;
   67: 
   68:         while ( (msg = (T_MSG_PRI*)nextmsg(prevmsg)) != NULL ) {
   69:                 if ( msg->msgpri > pk_msg->msgpri ) {
   70:                         break;
   71:                 }
   72:                 prevmsg = (T_MSG*)msg;
   73:         }
   74:         nextmsg(pk_msg) = msg;
   75:         nextmsg(prevmsg) = pk_msg;
   76: }
   77: 
   78: #endif /* _MAILBOX_H_ */