OS_Q.C(全)

·  阅读 18

本篇介绍以下内容:

  • 从队列中接收消息*OSQAccept (OS_EVENT  *pevent,INT8U *perr)

  • 建立一个消息队列OS_EVENT  *OSQCreate (void  **start,INT16U size)\

  • 删除消息队列OS_EVENT *OSQDel (OS_EVENT *pevent,INT8U opt,INT8U  perr)\

  • 清空消息队列OSQFlush (OS_EVENT *pevent)\

  • 任务等待消息队列中的消息*OSQPend (OS_EVENT  *pevent,INT32U timeout,INT8U  *perr)\

  • 取消等待消息的任务OSQPendAbort (OS_EVENT *pevent,INT8U opt,INT8U     *perr)

  • 给队列发送消息INT8U OSQPost (OS_EVENT *pevent,void *pmsg)

  • 通过消息队列向任务发送消息INT8U  OSQPostFront (OS_EVENT  *pevent,void *pmsg)\

  • 消息队列向任务发消息(允许广播消息)INT8U  OSQPostOpt (OS_EVENT  *pevent, void *pmsg,INT8U opt)\

  • 获得消息队列的信息INT8U  OSQQuery (OS_EVENT  *pevent,OS_Q_DATA *p_q_data)\

  • 队列单元初始化 OS_QInit (void)

从队列中接收消息*OSQAccept (OS_EVENT  *pevent,INT8U *perr):\

#if (OS_Q_EN > 0u) && (OS_MAX_QS > 0u)
/*2018/2/22
*********************************************************************************************************
*                                      ACCEPT MESSAGE FROM QUEUE
*				        从队列中接收消息
* Description: This function checks the queue to see if a message is available.  Unlike OSQPend(),
*              OSQAccept() does not suspend the calling task if a message is not available.
*描述:该功能是检测队列看是否有可获得的消息。与 OSQPend()不同的是,如果没有消息可以获得,
	OSQAccept()不会被挂起。
* Arguments  : pevent        is a pointer to the event control block
*参数:			--pevent:指向事件控制块的指针。
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*                            OS_ERR_NONE         The call was successful and your task received a
*                                                message.
*                            OS_ERR_EVENT_TYPE   You didn't pass a pointer to a queue
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
*                            OS_ERR_Q_EMPTY      The queue did not contain any messages
*				--perr:错误信息指针。
						OS_ERR_NONE:调用成功,任务接收到消息。
						OS_ERR_EVENT_TYPE:没有指向队列的指针;
						OS_ERR_PEVENT_NULL:pevent为空指针。
						OS_ERR_Q_EMPTY:队列中不包含消息。
* Returns    : != (void *)0  is the message in the queue if one is available.  The message is removed
*                            from the so the next time OSQAccept() is called, the queue will contain
*                            one less entry.
*              == (void *)0  if you received a NULL pointer message
*                            if the queue is empty or,
*                            if 'pevent' is a NULL pointer or,
*                            if you passed an invalid event type
*返回值:	!= (void *)0:如果队列中有可获得的消息,指向消息。该消息会被移出以便于下次调用OSQAccept()。
						队列包含至少一个入口。
		     == (void *)0:以下情况返回空:
				指向消息的指针为空;
				队列为空;
				pevent为空指针;
				事件类型无效。
* Note(s)    : As of V2.60, you can now pass NULL pointers through queues.  Because of this, the argument
*              'perr' has been added to the API to tell you about the outcome of the call.
*********************************************************************************************************
*/

#if OS_Q_ACCEPT_EN > 0u
void  *OSQAccept (OS_EVENT  *pevent,
                  INT8U     *perr)
{
    void      *pmsg;/*指向消息的指针*/
    OS_Q      *pq;/*指向队列的指针*/
	#if OS_CRITICAL_METHOD == 3u        
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#ifdef OS_SAFETY_CRITICAL
		if (perr == (INT8U *)0) {
			OS_SAFETY_CRITICAL_EXCEPTION();
		}
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {   
			*perr = OS_ERR_PEVENT_NULL;
			return ((void *)0);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {
        *perr = OS_ERR_EVENT_TYPE;
        return ((void *)0);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    pq = (OS_Q *)pevent->OSEventPtr; /*指向队列控制块的指针 */
    if (pq->OSQEntries > 0u) /*检测队列中是否有消息*/
	{       
        pmsg = *pq->OSQOut++; /*有消息,提取出最早进入队列的消息*/
        pq->OSQEntries--;  /* 将队列中消息数量减1*/
        if (pq->OSQOut == pq->OSQEnd) /*消息全部被取出*/
		{        
            pq->OSQOut = pq->OSQStart;/*首尾指针相等*/
        }
        *perr = OS_ERR_NONE;
    }
	else/*队列中没有消息*/
	{
        *perr = OS_ERR_Q_EMPTY;/*错误类型为OS_ERR_Q_EMPTY*/
        pmsg  = (void *)0;  /* 指向消息的指针设置为空*/
    }
    OS_EXIT_CRITICAL();/*退出中断*/
    return (pmsg); /* 返回接收到的消息或者空*/
}
#endif
复制代码

建立一个消息队列OS_EVENT  *OSQCreate (void  **start,INT16U  size):

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                        CREATE A MESSAGE QUEUE
*					建立一个消息队列
* Description: This function creates a message queue if free event control blocks are available.
*描述:该功能是当有空闲的事件控制块时创建一个消息队列。
* Arguments  : start         is a pointer to the base address of the message queue storage area.  The
*                            storage area MUST be declared as an array of pointers to 'void' as follows
*                            void *MessageStorage[size]
*参数:		--start:指向消息队列存储区域底部的指针。该存储区域必须被声明为void型指针数组。形式如下;void *MessageStorage[size]
*              size          is the number of elements in the storage area
*				--size:该存储区的成员数量。
* Returns    : != (OS_EVENT *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                                created queue
*              == (OS_EVENT *)0  if no event control blocks were available or an error was detected
	返回值:!= (OS_EVENT *)0:指向事件控制块的指针。
			== (OS_EVENT *)0:如果事件控制块不可获得或者有其他错误信息,返回空。
*********************************************************************************************************
*/

OS_EVENT  *OSQCreate (void    **start,
                      INT16U    size)
{
    OS_EVENT  *pevent;/*指向队列对应的事件控制块*/
    OS_Q      *pq;/*指向队列控制块的指针*/
	#if OS_CRITICAL_METHOD == 3u             
		OS_CPU_SR  cpu_sr = 0u;
	#endif
	
	#ifdef OS_SAFETY_CRITICAL_IEC61508
		if (OSSafetyCriticalStartFlag == OS_TRUE) {
			OS_SAFETY_CRITICAL_EXCEPTION();
		}
	#endif

    if (OSIntNesting > 0u) {    
        return ((OS_EVENT *)0);      
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    pevent = OSEventFreeList;/* 得到空闲的事件控制块*/
    if (OSEventFreeList != (OS_EVENT *)0) /*如果有可获得事件控制块*/
	{   
        OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;/*更新空闲事件列表*/
    }
    OS_EXIT_CRITICAL();/*退出中断*/
    if (pevent != (OS_EVENT *)0) /*如果获得了事件控制块*/
	{      
        OS_ENTER_CRITICAL();/*进入中断*/
        pq = OSQFreeList; /*获得空闲的队列控制块 */
        if (pq != (OS_Q *)0) /*如果获得了空闲的队列控制块*/
		{       
            OSQFreeList = OSQFreeList->OSQPtr; /*调整空闲列表指针到下一个*/
            OS_EXIT_CRITICAL();/*退出中断*/
            pq->OSQStart = start;/*初始化队列 头指针*/
            pq->OSQEnd = &start[size];/*尾指针*/
            pq->OSQIn = start;/*进入的指针*/
            pq->OSQOut = start;/*出去的指针*/
            pq->OSQSize = size;/*队列大小*/
            pq->OSQEntries = 0u;/*队列内的成员数初始化为0*/
            pevent->OSEventType = OS_EVENT_TYPE_Q;/*将事件控制块类型设置为队列类型*/
            pevent->OSEventCnt = 0u;
            pevent->OSEventPtr = pq;/*事件控制块指针指向队列*/
			#if OS_EVENT_NAME_EN > 0u
			pevent->OSEventName    = (INT8U *)(void *)"?";/*名字初始化为未命名*/
			#endif
            OS_EventWaitListInit(pevent);/*初始化等待列表 */
        } 
		else/*如果没有获得空闲的队列控制块*/
		{
            pevent->OSEventPtr = (void *)OSEventFreeList; /*将事件控制块还给事件空闲列表*/
            OSEventFreeList = pevent;
            OS_EXIT_CRITICAL();/*退出中断*/
            pevent = (OS_EVENT *)0;
        }
    }
    return (pevent);
}
复制代码

删除消息队列OS_EVENT  *OSQDel (OS_EVENT  *pevent,INT8U opt,INT8U *perr):

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                        DELETE A MESSAGE QUEUE
*					删除消息队列
* Description: This function deletes a message queue and readies all tasks pending on the queue.
*描述:该功能是删除消息队列并且将所有挂起的任务设置为就绪态。
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            queue.
*参数:		--pevent:指向与队列对应的事件控制块的指针
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete the queue ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the queue even if tasks are waiting.
*                                                    In this case, all the tasks pending will be readied.
*			--opt:选择删除方式:
				opt == OS_DEL_NO_PEND:没有任务挂起时才能删除。
				opt == OS_DEL_ALWAYS:即使有任务正在等待也将队列删除。在这种情况下,所有挂起的任务都转为就绪态。
*              perr          is a pointer to an error code that can contain one of the following values:
*                            OS_ERR_NONE             The call was successful and the queue was deleted
*                            OS_ERR_DEL_ISR          If you tried to delete the queue from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the queue
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a queue
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*				--perr:指向错误码的指针:
						OS_ERR_NONE:调用成功,队列被删除;
						OS_ERR_DEL_ISR:从中断服务子程序中删除队列;
						OS_ERR_INVALID_OPT:选择无效;
						OS_ERR_TASK_WAITING:一个或者多个任务正在等待该队列
						OS_ERR_EVENT_TYPE:没有指向队列的指针
						OS_ERR_PEVENT_NULL:pevent为空指针
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the queue was successfully deleted.
*返回值:如果成功删除队列,返回值为空,如果没有成功删除,返回pevent。
* Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
*                 the queue MUST check the return code of OSQPend().
*              2) OSQAccept() callers will not know that the intended queue has been deleted unless
*                 they check 'pevent' to see that it's a NULL pointer.
*              3) This call can potentially disable interrupts for a long time.  The interrupt disable
*                 time is directly proportional to the number of tasks waiting on the queue.
*              4) Because ALL tasks pending on the queue will be readied, you MUST be careful in
*                 applications where the queue is used for mutual exclusion because the resource(s)
*                 will no longer be guarded by the queue.
*              5) If the storage for the message queue was allocated dynamically (i.e. using a malloc()
*                 type call) then your application MUST release the memory storage by call the counterpart
*                 call of the dynamic allocation scheme used.  If the queue storage was created statically
*                 then, the storage can be reused.
注释:1)该函数一定要小心使用。等待队列的任务要检查OSQPend()的返回值。
	2)调用OSQAccept()的任务无法得知队列是否被删除,除非检测pevent是否为空指针。
	3)该函数调用会中断很长时间,中断的时间长短与等待任务的数量成正比。
	4)因为在删除后所有的任务都会从等待状态转为就绪态。所以如果队列中的消息为互斥量,调用需要小心。因为此时资源是开放的。
	5)如果消息队列内存是动态分配的,你的应用程序一定要通过对应的程序释放存储空间。如果空间是静态的,该空间可以被重新使用。
*********************************************************************************************************
*/

#if OS_Q_DEL_EN > 0u
OS_EVENT  *OSQDel (OS_EVENT  *pevent,
                   INT8U      opt,
                   INT8U     *perr)
{
    BOOLEAN    tasks_waiting;/*布尔型变量标志是否有任务正在等待*/
    OS_EVENT  *pevent_return;/*返回值*/
    OS_Q      *pq;/*指向队列的指针*/
	#if OS_CRITICAL_METHOD == 3u       
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#ifdef OS_SAFETY_CRITICAL
		if (perr == (INT8U *)0) {
			OS_SAFETY_CRITICAL_EXCEPTION();
		}
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {   
			*perr = OS_ERR_PEVENT_NULL;
			return (pevent);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {     
        *perr = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0u) {       
        *perr = OS_ERR_DEL_ISR;      
        return (pevent);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    if (pevent->OSEventGrp != 0u)/*有任务正在等待队列*/
	{    
        tasks_waiting = OS_TRUE;  /* 将等待标志设置为true */
    }
	else/*没有任务等待队列*/
	{
        tasks_waiting = OS_FALSE;/* 将等待标志设置为false*/
    }
    switch (opt) /*选择删除方式并进行对应操作*/
	{
        case OS_DEL_NO_PEND: /* 无挂起才删除*/
             if (tasks_waiting == OS_FALSE)/*无任务等待*/
			 {
				#if OS_EVENT_NAME_EN > 0u
					pevent->OSEventName    = (INT8U *)(void *)"?";/*名字初始化为未命名*/
				#endif
				/*将队列控制块还给空闲队列列表*/
                 pq = (OS_Q *)pevent->OSEventPtr;  
                 pq->OSQPtr = OSQFreeList;
                 OSQFreeList = pq;
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;/*将事件类型设置为未使用类型*/
                 pevent->OSEventPtr = OSEventFreeList; /*将事件控制块还给事件空闲列表*/
                 pevent->OSEventCnt = 0u;
                 OSEventFreeList = pevent; /*更新空闲事件列表*/   
                 OS_EXIT_CRITICAL();/*退出中断*/
                 *perr = OS_ERR_NONE;
                 pevent_return = (OS_EVENT *)0;   /* 队列已经被删除,返回空*/
             }
			 else/*有任务正在等待*/
			 {
                 OS_EXIT_CRITICAL();/*退出中断*/
                 *perr = OS_ERR_TASK_WAITING;/*设置错误类型*/
                 pevent_return = pevent;
             }
             break;

        case OS_DEL_ALWAYS:  /*有挂起也删除*/
             while (pevent->OSEventGrp != 0u)/*将所有等待的任务转为就绪态*/
			 {         
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_Q, OS_STAT_PEND_OK);
             }
			#if OS_EVENT_NAME_EN > 0u
						 pevent->OSEventName    = (INT8U *)(void *)"?";
			#endif
             pq = (OS_Q *)pevent->OSEventPtr;   /*同上*/
             pq->OSQPtr = OSQFreeList;
             OSQFreeList = pq;
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr = OSEventFreeList;   
             pevent->OSEventCnt = 0u;
             OSEventFreeList = pevent;           
             OS_EXIT_CRITICAL();
             if (tasks_waiting == OS_TRUE) /*有任务等待时才可能调度*/
			 {            
                 OS_Sched(); /*找到最高优先级任务并进行调度 */
             }
             *perr = OS_ERR_NONE;
             pevent_return = (OS_EVENT *)0;  /*队列被删除,返回值为空 */
             break;

        default:/*两种选择都不是*/
             OS_EXIT_CRITICAL();/*退出中断*/
             *perr  = OS_ERR_INVALID_OPT;/*设置错误类型*/
             pevent_return = pevent;
             break;
    }
    return (pevent_return);
}
#endif
复制代码

清空消息队列并且忽略发送往队列的所有消息OSQFlush (OS_EVENT *pevent):

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                             FLUSH QUEUE
*							清空消息队列并且忽略发送往队列的所有消息
* Description : This function is used to flush the contents of the message queue.
*描述:该功能用来清空消息队列的内容。
* Arguments   : none
*参数:无
* Returns     : OS_ERR_NONE         upon success
*               OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a queue
*               OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
*返回值:OS_ERR_NONE;成功调用。
		OS_ERR_EVENT_TYPE:没有指向队列的指针。
		OS_ERR_PEVENT_NULL:pevent为空指针。
* WARNING     : You should use this function with great care because, when to flush the queue, you LOOSE
*               the references to what the queue entries are pointing to and thus, you could cause
*               'memory leaks'.  In other words, the data you are pointing to that's being referenced
*               by the queue entries should, most likely, need to be de-allocated (i.e. freed).
	警告:需要特别小心使用该函数,因为当清空队列的时候,会释放队列中成员指向的一些内容,容易造成内存泄漏。
		换句话说,在使用完队列后应该动态释放空间。
*********************************************************************************************************
*/

#if OS_Q_FLUSH_EN > 0u
INT8U  OSQFlush (OS_EVENT *pevent)
{
    OS_Q      *pq;/*指向队列的指针*/
	#if OS_CRITICAL_METHOD == 3u    
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {               
			return (OS_ERR_PEVENT_NULL);
		}
		if (pevent->OSEventType != OS_EVENT_TYPE_Q) {    
			return (OS_ERR_EVENT_TYPE);
		}
	#endif
    OS_ENTER_CRITICAL();/*进入中断*/
    pq = (OS_Q *)pevent->OSEventPtr; /* pq指向队列存储结构 */
    pq->OSQIn = pq->OSQStart;/*进入队列指针*/
    pq->OSQOut = pq->OSQStart;/*出队列指针,首尾指向该队列的开始*/
    pq->OSQEntries = 0u;
    OS_EXIT_CRITICAL();/*退出中断*/
    return (OS_ERR_NONE);
}
#endif
复制代码

任务等待消息队列中的消息*OSQPend (OS_EVENT  *pevent,INT32U timeout,INT8U *perr):

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                     PEND ON A QUEUE FOR A MESSAGE
*				    任务等待消息队列中的消息
* Description: This function waits for a message to be sent to a queue
*描述:该功能是等待消息队列中的消息
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*参数:		--pevent:指向事件控制块的指针
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for a message to arrive at the queue up to the amount of time
*                            specified by this argument.  If you specify 0, however, your task will wait
*                            forever at the specified queue or, until a message arrives.
*		--timeout:可选择的时间片。如果不为0,任务将会等待消息,到时间到达了设定的时间后不再等待。如果是0,
				任务就会一直等待,知道有消息到来。
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*                            OS_ERR_NONE         The call was successful and your task received a message.
*                            OS_ERR_TIMEOUT      A message was not received within the specified 'timeout'.
*                            OS_ERR_PEND_ABORT   The wait on the queue was aborted.
*                            OS_ERR_EVENT_TYPE   You didn't pass a pointer to a queue
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEND_LOCKED  If you called this function with the scheduler is locked
*		--perr:指向错误码的指针:‘
				OS_ERR_NONE:成功调用,任务收到消息。
				OS_ERR_TIMEOUT:超时错。
				OS_ERR_PEND_ABORT:任务被取消。
				OS_ERR_EVENT_TYPE:没有指向队列的指针。
				OS_ERR_PEVENT_NULL:pevent为空指针。
				OS_ERR_PEND_ISR:从中断服务子程序中调用该功能。
				OS_ERR_PEND_LOCKED:调度程序被锁
* Returns    : != (void *)0  is a pointer to the message received
*              == (void *)0  if you received a NULL pointer message or,
*                            if no message was received or,
*                            if 'pevent' is a NULL pointer or,
*                            if you didn't pass a pointer to a queue.
*返回值:!= (void *)0:指向收到的消息
		 == (void *)0:以下几种情况返回值为空:
			指向消息的指针为空;
			没有收到消息;
			pevent为空指针;
			没有指向队列的指针。
* Note(s)    : As of V2.60, this function allows you to receive NULL pointer messages.
注释:对于V2.60版本,该功能允许收到空指针消息。
*********************************************************************************************************
*/

void  *OSQPend (OS_EVENT  *pevent,
                INT32U     timeout,
                INT8U     *perr)
{
    void      *pmsg;/*指向消息的指针*/
    OS_Q      *pq;/*指向队列控制块的指针*/
	#if OS_CRITICAL_METHOD == 3u   
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#ifdef OS_SAFETY_CRITICAL
		if (perr == (INT8U *)0) {
			OS_SAFETY_CRITICAL_EXCEPTION();
		}
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {  
			*perr = OS_ERR_PEVENT_NULL;
			return ((void *)0);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {
        *perr = OS_ERR_EVENT_TYPE;
        return ((void *)0);
    }
    if (OSIntNesting > 0u) {          
        *perr = OS_ERR_PEND_ISR;                
        return ((void *)0);
    }
    if (OSLockNesting > 0u) {             
        *perr = OS_ERR_PEND_LOCKED;         
        return ((void *)0);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    pq = (OS_Q *)pevent->OSEventPtr;/*指向队列控制块的指针*/
    if (pq->OSQEntries > 0u)/*在队列中有消息*/
	{       
        pmsg = *pq->OSQOut++; /*从队列中取出最早进入的消息 */
        pq->OSQEntries--; /*更新队列的数量*/
        if (pq->OSQOut == pq->OSQEnd) /*队列中没有消息了*/
		{    
            pq->OSQOut = pq->OSQStart;/*将出队列的指针指向队列首*/
        }
        OS_EXIT_CRITICAL();/*退出中断*/
        *perr = OS_ERR_NONE;
        return (pmsg);/* 返回收到的消息*/
    }
	/*队列中没有消息*/
    OSTCBCur->OSTCBStat |= OS_STAT_Q;/*将事件进入睡眠状态,由消息队列唤醒*/
    OSTCBCur->OSTCBStatPend  = OS_STAT_PEND_OK;
    OSTCBCur->OSTCBDly = timeout; /*等待时间置入任务控制中*/
    OS_EventTaskWait(pevent);/*使任务进入等待消息队列状态*/
    OS_EXIT_CRITICAL();/*退出中断*/
    OS_Sched(); /* 找到最高优先级任务并调度 */
    OS_ENTER_CRITICAL();/*进入中断*/
    switch (OSTCBCur->OSTCBStatPend) /*看挂起状态是超时还是被取消*/
	{       
        case OS_STAT_PEND_OK:/*得到消息*/
             pmsg =  OSTCBCur->OSTCBMsg;
            *perr =  OS_ERR_NONE;
             break;

        case OS_STAT_PEND_ABORT:/*任务被取消*/
             pmsg = (void *)0;
            *perr =  OS_ERR_PEND_ABORT;  
             break;

        case OS_STAT_PEND_TO:/*超时*/
        default:
             OS_EventTaskRemove(OSTCBCur, pevent);
             pmsg = (void *)0;
            *perr =  OS_ERR_TIMEOUT;   
             break;
    }
    OSTCBCur->OSTCBStat =  OS_STAT_RDY;/*将任务状态设置为就绪态*/
    OSTCBCur->OSTCBStatPend = OS_STAT_PEND_OK;  /* 清除挂起状态*/
    OSTCBCur->OSTCBEventPtr = (OS_EVENT  *)0;/* 清除事件指针 */
	#if (OS_EVENT_MULTI_EN > 0u)
		OSTCBCur->OSTCBEventMultiPtr = (OS_EVENT **)0;
	#endif
    OSTCBCur->OSTCBMsg = (void *)0;    /*清除收到的消息*/
    OS_EXIT_CRITICAL();/*退出中断*/
    return (pmsg); /* 返回收到的消息*/
}
复制代码

取消等待的任务INT8U  OSQPendAbort (OS_EVENT  *pevent,INT8U  opt,INT8U  *perr):

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                      ABORT WAITING ON A MESSAGE QUEUE
*					取消等待消息的任务
* Description: This function aborts & readies any tasks currently waiting on a queue.  This function
*              should be used to fault-abort the wait on the queue, rather than to normally signal
*              the queue via OSQPost(), OSQPostFront() or OSQPostOpt().
*描述:该功能是将所有等待队列消息的任务取消并转为就绪态。该功能是默认取消等待,而不是通过OSQPost(),
		OSQPostFront()或者OSQPostOpt()通知队列。
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue.
*参数:		--pevent:指向队列对应的事件控制块的指针。
*              opt           determines the type of ABORT performed:
*                            OS_PEND_OPT_NONE         ABORT wait for a single task (HPT) waiting on the
*                                                     queue
*                            OS_PEND_OPT_BROADCAST    ABORT wait for ALL tasks that are  waiting on the
*                                                     queue
*			--opt:取消的方式:
				OS_PEND_OPT_NONE:只取消最高优先级任务;
				OS_PEND_OPT_BROADCAST:取消所有任务。
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*                            OS_ERR_NONE         No tasks were     waiting on the queue.
*                            OS_ERR_PEND_ABORT   At least one task waiting on the queue was readied
*                                                and informed of the aborted wait; check return value
*                                                for the number of tasks whose wait on the queue
*                                                was aborted.
*                            OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a queue.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer.
			--perr:指向错误码的指针:
				OS_ERR_NONE:没有任务等待队列消息。
				OS_ERR_PEND_ABORT:至少一个等待队列消息的任务是就绪的并且被取消等待;检查任务数的返回值。
				OS_ERR_EVENT_TYPE:没有指向队列的指针;
				OS_ERR_PEVENT_NULL:pevent为空指针。
* Returns    : == 0          if no tasks were waiting on the queue, or upon error.
*              >  0          if one or more tasks waiting on the queue are now readied and informed.
	返回值:== 0:没有任务等待队列。
			>  0:一个或多个等待队列的任务为就绪态并且被取消。
*********************************************************************************************************
*/

#if OS_Q_PEND_ABORT_EN > 0u
INT8U  OSQPendAbort (OS_EVENT  *pevent,
                     INT8U      opt,
                     INT8U     *perr)
{
    INT8U      nbr_tasks;/*等待的任务数目*/
	#if OS_CRITICAL_METHOD == 3u           
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#ifdef OS_SAFETY_CRITICAL
		if (perr == (INT8U *)0) {
			OS_SAFETY_CRITICAL_EXCEPTION();
		}
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {   
			*perr = OS_ERR_PEVENT_NULL;
			return (0u);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {    
        *perr = OS_ERR_EVENT_TYPE;
        return (0u);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    if (pevent->OSEventGrp != 0u) /*有任务正在等待*/
	{    
        nbr_tasks = 0u;/*数量先初始化为0*/
        switch (opt) /*选择取消的类型*/
		{
            case OS_PEND_OPT_BROADCAST: /*取消所有的任务*/
                 while (pevent->OSEventGrp != 0u)
				 {    
                     (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_Q, OS_STAT_PEND_ABORT);
                     nbr_tasks++;
                 }
                 break;

            case OS_PEND_OPT_NONE:/*只取消优先级最高的那个任务*/
            default: /*取消任务就是不让该任务处于等待状态,转为就绪态*/
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_Q, OS_STAT_PEND_ABORT);
                 nbr_tasks++;
                 break;
        }
        OS_EXIT_CRITICAL();/*退出中断*/
        OS_Sched(); /*找到最高优先级任务并调度*/
        *perr = OS_ERR_PEND_ABORT;
        return (nbr_tasks);/*返回任务的数目*/
    }
    OS_EXIT_CRITICAL();/*退出中断*/
    *perr = OS_ERR_NONE;
    return (0u);  /*如果没有任务等待的话,返回0*/
}
#endif
复制代码

该函数最后是返回取消的任务数目。如果有任务正在等待队列消息,取消后返回任务数量。如果没有任务等待,返回0。取消等待的任务实际上就是将任务从等待状态转为就绪态。

给队列发送消息INT8U  OSQPost (OS_EVENT  *pevent,void   *pmsg):\

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                        POST MESSAGE TO A QUEUE
*										给队列发送消息
* Description: This function sends a message to a queue
*描述:该功能是将消息发送给队列。
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*参数:	--pevent:指向队列对应的事件控制块的指针
*              pmsg          is a pointer to the message to send.
*		--pmsg:指向发送的消息的指针。
* Returns    : OS_ERR_NONE           The call was successful and the message was sent
*              OS_ERR_Q_FULL         If the queue cannot accept any more messages because it is full.
*              OS_ERR_EVENT_TYPE     If you didn't pass a pointer to a queue.
*              OS_ERR_PEVENT_NULL    If 'pevent' is a NULL pointer
*返回值:OS_ERR_NONE:成功调用,消息被发送。
		OS_ERR_Q_FULL:队列已满,不能接收新的消息。
		OS_ERR_EVENT_TYPE:没有指向队列的指针。
		OS_ERR_PEVENT_NULL:pevent为空指针。
* Note(s)    : As of V2.60, this function allows you to send NULL pointer messages.
注释:对于V2.60版本,该功能允许发送空指针消息。
*********************************************************************************************************
*/

#if OS_Q_POST_EN > 0u
INT8U  OSQPost (OS_EVENT  *pevent,
                void      *pmsg)
{
    OS_Q      *pq;/*指向队列的指针*/
	#if OS_CRITICAL_METHOD == 3u    
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {        
			return (OS_ERR_PEVENT_NULL);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {    
        return (OS_ERR_EVENT_TYPE);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    if (pevent->OSEventGrp != 0u)/*有任务在等待队列消息*/
	{                 
        /* 将最高优先级任务设为就绪态 */
        (void)OS_EventTaskRdy(pevent, pmsg, OS_STAT_Q, OS_STAT_PEND_OK);
        OS_EXIT_CRITICAL();/*退出中断*/
        OS_Sched();/*找到最高优先级任务并调度*/
        return (OS_ERR_NONE);
    }
	/*没有任务等待队列消息*/
    pq = (OS_Q *)pevent->OSEventPtr;  /* 指针指向队列控制块 */
    if (pq->OSQEntries >= pq->OSQSize)/*队列已满*/
	{             
        OS_EXIT_CRITICAL();/*退出中断*/
        return (OS_ERR_Q_FULL);
    }
	/*队列不满*/
    *pq->OSQIn++ = pmsg;/* 将消息插入到队列中 */
    pq->OSQEntries++;  /* 将队列的消息数量进行更新 */
    if (pq->OSQIn == pq->OSQEnd)/*如果此时队列满了*/
	{               
        pq->OSQIn = pq->OSQStart;/*将进入队列指针指向队列首*/
    }
    OS_EXIT_CRITICAL();/*退出中断*/
    return (OS_ERR_NONE);
}
#endif
复制代码

通过消息队列向任务发送消息INT8U  OSQPostFront (OS_EVENT  *pevent, void *pmsg):

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                   POST MESSAGE TO THE FRONT OF A QUEUE
*				通过消息队列向任务发送消息
* Description: This function sends a message to a queue but unlike OSQPost(), the message is posted at
*              the front instead of the end of the queue.  Using OSQPostFront() allows you to send
*              'priority' messages.
*描述:该功能是给队列发送消息,但是与OSQPost()不同,这个消息是发送给队列的开始,而不是结尾。
		OSQPostFront()允许你发送优先级高的消息。(消息队列按照后入先出(LIFO)的方式工作, 而不是先入先出(FIFO))
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*参数:	--pevent:指向事件控制块的指针。
*              pmsg          is a pointer to the message to send.
*		--pmsg:指向要发送的消息的指针。
* Returns    : OS_ERR_NONE           The call was successful and the message was sent
*              OS_ERR_Q_FULL         If the queue cannot accept any more messages because it is full.
*              OS_ERR_EVENT_TYPE     If you didn't pass a pointer to a queue.
*              OS_ERR_PEVENT_NULL    If 'pevent' is a NULL pointer
*返回值:OS_ERR_NONE:调用成功,消息被发出。
		OS_ERR_Q_FULL:队列已满,不能接收消息。
		OS_ERR_EVENT_TYPE:没有指向队列的指针。
		OS_ERR_PEVENT_NULL:pevent为空指针。
* Note(s)    : As of V2.60, this function allows you to send NULL pointer messages.
	注释:在V2.60版本中,该功能允许发送空指针消息。
*********************************************************************************************************
*/

#if OS_Q_POST_FRONT_EN > 0u
INT8U  OSQPostFront (OS_EVENT  *pevent,
                     void      *pmsg)
{
    OS_Q      *pq;/*指向消息队列的指针*/
	#if OS_CRITICAL_METHOD == 3u    
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {     
			return (OS_ERR_PEVENT_NULL);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {    
        return (OS_ERR_EVENT_TYPE);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    if (pevent->OSEventGrp != 0u)/*有任务正在等待队列消息*/
	{  
         /*将最高优先级任务转为就绪态*/
        (void)OS_EventTaskRdy(pevent, pmsg, OS_STAT_Q, OS_STAT_PEND_OK);
        OS_EXIT_CRITICAL();/*退出中断*/
        OS_Sched(); /* 找到最高优先级任务并调度 */
        return (OS_ERR_NONE);
    }
	/*没有任务等待消息*/
    pq = (OS_Q *)pevent->OSEventPtr; /* 指向队列控制块的指针*/
    if (pq->OSQEntries >= pq->OSQSize)/*队列已满*/
	{          
        OS_EXIT_CRITICAL();/*退出中断*/
        return (OS_ERR_Q_FULL);
    }
    if (pq->OSQOut == pq->OSQStart) /*当插入指针=指针的起始地址(指针)*/
	{              
        pq->OSQOut = pq->OSQEnd;/*插入指针跳转到最后地址(指针)*/
    }
    pq->OSQOut--;/*插入指针减1*/
    *pq->OSQOut = pmsg; /*插入当前消息(内容) */
    pq->OSQEntries++;/* 消息数加1 */
    OS_EXIT_CRITICAL();/*退出中断*/
    return (OS_ERR_NONE);
}
#endif
复制代码

该函数与上一个函数十分相似,不同点在于这个函数是将消息插入到队列的最前端。这样就让队列的进出方式从FIFO(先进先出)变成了LIFO(后进先出)。

消息队列向任务发消息(允许广播消息)INT8U  OSQPostOpt (OS_EVENT  *pevent,void *pmsg,INT8U  opt):\

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                        POST MESSAGE TO A QUEUE
*					消息队列向任务发消息(允许广播消息)
* Description: This function sends a message to a queue.  This call has been added to reduce code size
*              since it can replace both OSQPost() and OSQPostFront().  Also, this function adds the
*              capability to broadcast a message to ALL tasks waiting on the message queue.
*描述:该功能将消息发送给队列。该函数可以减少代码长度因为它可以代替OSQPost() 和 OSQPostFront()。
		该功能允许广播消息给所有等待消息的任务。
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*参数:		--pevent:指向事件控制块的指针。
*              pmsg          is a pointer to the message to send.
*			--pmsg:指向被发送消息的指针。
*              opt           determines the type of POST performed:
*                            OS_POST_OPT_NONE         POST to a single waiting task
*                                                     (Identical to OSQPost())
*                            OS_POST_OPT_BROADCAST    POST to ALL tasks that are waiting on the queue
*                            OS_POST_OPT_FRONT        POST as LIFO (Simulates OSQPostFront())
*                            OS_POST_OPT_NO_SCHED     Indicates that the scheduler will NOT be invoked
*			--opt:选择发送消息方式:
				OS_POST_OPT_NONE:只给一个等待的任务发送消息,与 OSQPost()相同。
				OS_POST_OPT_BROADCAST:向所有等待消息的任务发送消息。
				OS_POST_OPT_FRONT:与OSQPostFront()相同,消息进入队列方式为LIFO。
				OS_POST_OPT_NO_SCHED:调度函数将不会被唤醒,
* Returns    : OS_ERR_NONE           The call was successful and the message was sent
*              OS_ERR_Q_FULL         If the queue cannot accept any more messages because it is full.
*              OS_ERR_EVENT_TYPE     If you didn't pass a pointer to a queue.
*              OS_ERR_PEVENT_NULL    If 'pevent' is a NULL pointer
*返回值:OS_ERR_NONE:调用成功,消息被发出。
		OS_ERR_Q_FULL:队列已满,无法接收消息。
		OS_ERR_EVENT_TYPE:没有指向队列的指针。
		OS_ERR_PEVENT_NULL:pevent为空指针。
* Warning    : Interrupts can be disabled for a long time if you do a 'broadcast'.  In fact, the
*              interrupt disable time is proportional to the number of tasks waiting on the queue.
	警告:该函数调用后可能会中断很长时间如果选择的是broadcast(广播)方式。中断时间与等待的任务数有关。
*********************************************************************************************************
*/

#if OS_Q_POST_OPT_EN > 0u
INT8U  OSQPostOpt (OS_EVENT  *pevent,
                   void      *pmsg,
                   INT8U      opt)
{
    OS_Q      *pq;/*指向消息队列的指针*/
	#if OS_CRITICAL_METHOD == 3u   
		OS_CPU_SR  cpu_sr = 0u;
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {        
			return (OS_ERR_PEVENT_NULL);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {  
        return (OS_ERR_EVENT_TYPE);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
    if (pevent->OSEventGrp != 0x00u) /*有任务正在等待消息*/
	{     
        if ((opt & OS_POST_OPT_BROADCAST) != 0x00u) /*选择的方式为广播方式(给所有任务发消息)*/
		{
            while (pevent->OSEventGrp != 0u) /*给所有任务发消息*/
			{       
                (void)OS_EventTaskRdy(pevent, pmsg, OS_STAT_Q, OS_STAT_PEND_OK);
            }
        }
		else /*不是广播方式,将消息发送给优先级最高的任务*/
		{                               
            (void)OS_EventTaskRdy(pevent, pmsg, OS_STAT_Q, OS_STAT_PEND_OK);
        }
        OS_EXIT_CRITICAL();/*退出中断*/
        if ((opt & OS_POST_OPT_NO_SCHED) == 0u) /*调度程序没有被唤醒*/
		{	
            OS_Sched(); /*找到最高优先级任务并调度 */
        }
        return (OS_ERR_NONE);
    }
	/*没有任务等待消息*/
    pq = (OS_Q *)pevent->OSEventPtr;/* 指向队列控制块的指针 */
    if (pq->OSQEntries >= pq->OSQSize)/*队列已满*/
	{        
        OS_EXIT_CRITICAL();/*退出中断*/
        return (OS_ERR_Q_FULL);
    }
	/*队列不满*/
    if ((opt & OS_POST_OPT_FRONT) != 0x00u)/*将消息放在队列的最前面*/
	{       
        if (pq->OSQOut == pq->OSQStart)
		{     
            pq->OSQOut = pq->OSQEnd;          
        }
        pq->OSQOut--;
        *pq->OSQOut = pmsg;                     
    } 
	else/*FIFO方式*/
	{                             
        *pq->OSQIn++ = pmsg;     
        if (pq->OSQIn == pq->OSQEnd) {  
            pq->OSQIn = pq->OSQStart;
        }
    }
    pq->OSQEntries++;   /* 更新队列中的数目 */
    OS_EXIT_CRITICAL();/*退出中断*/
    return (OS_ERR_NONE);
}
#endif
复制代码

获得消息队列的信息INT8U  OSQQuery (OS_EVENT  *pevent,OS_Q_DATA *p_q_data):

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                        QUERY A MESSAGE QUEUE
*					获得消息队列的信息
* Description: This function obtains information about a message queue.
*描述:该功能是获得消息队列的信息。
* Arguments  : pevent        is a pointer to the event control block associated with the desired queue
*参数:	--pevent:指向事件控制块的指针。
*              p_q_data      is a pointer to a structure that will contain information about the message queue.
*		--p_q_data:指向结构体的指针,该指针包含消息队列的信息。
* Returns    : OS_ERR_NONE         The call was successful and the message was sent
*              OS_ERR_EVENT_TYPE   If you are attempting to obtain data from a non queue.
*              OS_ERR_PEVENT_NULL  If 'pevent'   is a NULL pointer
*              OS_ERR_PDATA_NULL   If 'p_q_data' is a NULL pointer
	返回值:OS_ERR_NONE:调用成功,消息被发出。
			OS_ERR_EVENT_TYPE:对象不是队列。
			OS_ERR_PEVENT_NULL:pevent为空指针。
			OS_ERR_PDATA_NULL:p_q_data为空指针。
*********************************************************************************************************
*/

#if OS_Q_QUERY_EN > 0u
INT8U  OSQQuery (OS_EVENT  *pevent,
                 OS_Q_DATA *p_q_data)
{
    OS_Q       *pq;/*指向队列的指针*/
    INT8U       i;
    OS_PRIO    *psrc;/*指向源*/
    OS_PRIO    *pdest;/*指向目的*/
	#if OS_CRITICAL_METHOD == 3u          
		OS_CPU_SR   cpu_sr = 0u;
	#endif

	#if OS_ARG_CHK_EN > 0u
		if (pevent == (OS_EVENT *)0) {   
			return (OS_ERR_PEVENT_NULL);
		}
		if (p_q_data == (OS_Q_DATA *)0) {                 
			return (OS_ERR_PDATA_NULL);
		}
	#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {  
        return (OS_ERR_EVENT_TYPE);
    }
    OS_ENTER_CRITICAL();/*进入中断*/
	/*将事件(消息队列)结构中的等待任务列表复制到pdata数据结构中*/
    p_q_data->OSEventGrp = pevent->OSEventGrp; /* 等待事件的任务组中的内容传送到状态数据结构中*/
    psrc = &pevent->OSEventTbl[0];/*保存pevent->OSEventTbl[0]对应的地址*/
    pdest = &p_q_data->OSEventTbl[0];/*保存pdata->OSEventTbl[0]对应的地址*/
    for (i = 0u; i < OS_EVENT_TBL_SIZE; i++) 
	{
        *pdest++ = *psrc++;/*地址指针下移一个类型地址,获取信号量的值*/
    }
    pq = (OS_Q *)pevent->OSEventPtr;/*将队列事件指针保存到pq 中*/
    if (pq->OSQEntries > 0u)/*如果消息队列指针中有消息*/
	{
        p_q_data->OSMsg = *pq->OSQOut; /* 将最早进入队列得消息复制到数据结构的OSMsg中  */
    } 
	else
	{
        p_q_data->OSMsg = (void *)0;/*如果队列中没有消息(包含一个空指针)*/
    }
    p_q_data->OSNMsgs = pq->OSQEntries;/*消息队列中的消息数放置在数据结构的(OSNMsgs)中*/
    p_q_data->OSQSize = pq->OSQSize;/*消息队列中的消息队列容量放置在数据结构得(OSQSize)中*/
    OS_EXIT_CRITICAL();/*退出中断*/
    return (OS_ERR_NONE);
}
#endif 
复制代码

获得消息队列的信息实际上就是将队列中的消息复制到队列对应的结构体中(p_q_data)。

队列单元初始化void  OS_QInit (void):\

/*$PAGE*/
/*2018/2/22
*********************************************************************************************************
*                                      QUEUE MODULE INITIALIZATION
*				队列单元初始化
* Description : This function is called by uC/OS-II to initialize the message queue module.  Your
*               application MUST NOT call this function.
*描述:该功能有uc/os-ii调用,来初始化消息队列单元。你的应用程序不能调用该函数
* Arguments   :  none
*参数:无
* Returns     : none
*返回值:无
* Note(s)    : This function is INTERNAL to uC/OS-II and your application should not call it.
注释:该功能为内部函数,你的应用程序不能调用。
*********************************************************************************************************
*/

void  OS_QInit (void)
{
	#if OS_MAX_QS == 1u/*只有一个队列*/
		OSQFreeList  = &OSQTbl[0];/*队列空闲列表只指向一个对象*/
		OSQFreeList->OSQPtr = (OS_Q *)0;/*没有指向下一个的指针。*/
	#endif

	#if OS_MAX_QS >= 2u/*队列不止一个*/
		INT16U   ix;
		INT16U   ix_next;
		OS_Q    *pq1;/*第一个指向队列的指针*/
		OS_Q    *pq2;/*第二个指向队列的指针*/

    OS_MemClr((INT8U *)&OSQTbl[0], sizeof(OSQTbl));  /*清除队列表*/
    for (ix = 0u; ix < (OS_MAX_QS - 1u); ix++)/*初始化空闲队列控制块列表*/
	{   
        ix_next = ix + 1u;
        pq1 = &OSQTbl[ix];
        pq2 = &OSQTbl[ix_next];
        pq1->OSQPtr = pq2;
    }
    pq1 = &OSQTbl[ix];
    pq1->OSQPtr = (OS_Q *)0;
    OSQFreeList = &OSQTbl[0];
#endif
}
复制代码

到这里整个OS_Q.C文件就看完了。在之前学习的基础上,这个文件就很简单了。现在的文件内容看起来思路和之前的文件思路相仿,很容易理解。所以没有做太多解释。注释很清晰。\

\

\

分类:
代码人生
标签: