os_msg.c

typedef  struct  os_msg               OS_MSG;
typedef  struct  os_msg_pool          OS_MSG_POOL;
typedef  struct  os_msg_q             OS_MSG_Q;


struct  os_msg {                                            /* MESSAGE CONTROL BLOCK                                  */
     OS_MSG              *NextPtr;                           /* Pointer to next message                                */
    void                *MsgPtr;                            /* Actual message                                         */
    OS_MSG_SIZE          MsgSize;                           /* Size of the message (in # bytes)                       */
    CPU_TS               MsgTS;                             /* Time stamp of when message was sent                    */
};

struct  os_msg_pool {                                       /* OS_MSG POOL                                            */
     OS_MSG               *NextPtr;                           /* Pointer to next message                                */
    OS_MSG_QTY           NbrFree;                           /* Number of messages available from this pool            */
    OS_MSG_QTY           NbrUsed;                           /* Current number of messages used                        */
    OS_MSG_QTY           NbrUsedMax;                        /* Peak number of messages used                           */
};

struct  os_msg_q {                                          /* OS_MSG_Q                                               */
     OS_MSG              *InPtr;                             /* Pointer to next OS_MSG to be inserted  in   the queue  */
     OS_MSG               *OutPtr;                            /* Pointer to next OS_MSG to be extracted from the queue  */
    OS_MSG_QTY           NbrEntriesSize;                    /* Maximum allowable number of entries in the queue       */
    OS_MSG_QTY           NbrEntries;                        /* Current number of entries in the queue                 */
    OS_MSG_QTY           NbrEntriesMax;                     /* Peak number of entries in the queue                    */
};





void  OS_MsgPoolInit (OS_ERR  *p_err):
    初始化 OSMsgPool内的OS_MSGs,OS内部函数,OSInit()调用。

OS_MSG_QTY  OS_MsgQFreeAll (OS_MSG_Q  *p_msg_q):
    将p_msg_q中的所有的OS_MSG放回到OSMsgPool中。

void  OS_MsgQInit (OS_MSG_Q    *p_msg_q,
                   OS_MSG_QTY   size):
    初始化p_msg_q->InPtr、OutPtr、 NbrEntriesSize、 NbrEntries、 NbrEntriesMax,OS内部函数。

void  *OS_MsgQGet (OS_MSG_Q     *p_msg_q,
                   OS_MSG_SIZE  *p_msg_size,
                   CPU_TS       *p_ts,
                   OS_ERR       *p_err):
    从p_msg_q中取出OS_MSG,获取里面的信息,放回到OSMsgPool中。

void  OS_MsgQPut (OS_MSG_Q     *p_msg_q,
                  void         *p_void,
                  OS_MSG_SIZE   msg_size,
                  OS_OPT        opt,
                  CPU_TS        ts,
                  OS_ERR       *p_err):
    将一个OS_MSG放入到p_msg_q中。
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值