8.清空消息队列
pq = (OS_Q*)pevent->OSEventPtr; /* Point toqueue storage structure */
pq->OSQIn =pq->OSQStart;
pq->OSQOut =pq->OSQStart;
pq->OSQEntries = 0;
9.获取消息队列的状态
消息队列状态结构
typedef struct {
void *OSMsg; /* Pointer to next message to beextracted from queue */
INT16U OSNMsgs; /* Number of messages in messagequeue */
INT16U OSQSize; /* Size of message queue */
INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /*List of tasks waiting for event to occur */
INT8U OSEventGrp; /* Group corresponding to taskswaiting for event to occur */
} OS_Q_DATA;
INT8U OSQQuery (OS_EVENT*pevent, OS_Q_DATA *ppdata) reentrant
{
OS_ENTER_CRITICAL();
//将事件(消息队列)结构中的等待任务列表复制到pdata数据结构中
ppdata->OSEventGrp =pevent->OSEventGrp; /*Copy message queue wait list */
psrc = &pevent->OSEventTbl[0];
pdest = &ppdata->OSEventTbl[0];
#if OS_EVENT_TBL_SIZE > 0 //当事件就绪对应表中的对应值>0时
*pdest++ = *psrc++; //地址指针下移一个类型地址,获取信号量的值
#endif
#if OS_EVENT_TBL_SIZE > 1
*pdest++ = *psrc++;
#endif
#if OS_EVENT_TBL_SIZE > 2
*pdest++ = *psrc++;
#endif
#if OS_EVENT_TBL_SIZE > 3
*pdest++ = *psrc++;
#endif
#if OS_EVENT_TBL_SIZE > 4
*pdest++ = *psrc++;
#endif
#if OS_EVENT_TBL_SIZE > 5
*pdest++ = *psrc++;
#endif
#if OS_EVENT_TBL_SIZE > 6
*pdest++ = *psrc++;
#endif
#if OS_EVENT_TBL_SIZE > 7
*pdest = *psrc;
#endif
pq = (OS_Q*)pevent->OSEventPtr; //将队列事件指针保存到pq 中
if (pq->OSQEntries > 0){ //如果消息队列指针中有消息
ppdata->OSMsg =*pq->OSQOut; /* Get next message to return if available 将最早进入队列得消息复制到数据结构的OSMsg中 */
} else {
ppdata->OSMsg = (void*)0;
}
ppdata->OSNMsgs =pq->OSQEntries; //消息队列中的消息数放置在数据结构的(OSNMsgs)中
ppdata->OSQSize =pq->OSQSize; //消息队列中的消息队列容量放置在数据结构得(OSQSize)中
OS_EXIT_CRITICAL();
return (OS_NO_ERR);
}
文章评论(0条评论)
登录后参与讨论