亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? os_q.c

?? 《嵌入式實時操作系統(tǒng)μC/OS-Ⅱ》的源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                        MESSAGE QUEUE MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_Q.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.h"
#endif

#if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
/*
*********************************************************************************************************
*                                      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.
*
* Arguments  : pevent        is a pointer to the event control block
*
* 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 the queue is empty or,
*                            if 'pevent' is a NULL pointer or,
*                            if you passed an invalid event type
*********************************************************************************************************
*/

#if OS_Q_ACCEPT_EN > 0
void  *OSQAccept (OS_EVENT *pevent)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif
    void      *msg;
    OS_Q      *pq;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {               /* Validate 'pevent'                                  */
        return ((void *)0);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type                          */
        return ((void *)0);
    }
#endif
    OS_ENTER_CRITICAL();
    pq = (OS_Q *)pevent->OSEventPtr;             /* Point at queue control block                       */
    if (pq->OSQEntries > 0) {                    /* See if any messages in the queue                   */
        msg = *pq->OSQOut++;                     /* Yes, extract oldest message from the queue         */
        pq->OSQEntries--;                        /* Update the number of entries in the queue          */
        if (pq->OSQOut == pq->OSQEnd) {          /* Wrap OUT pointer if we are at the end of the queue */
            pq->OSQOut = pq->OSQStart;
        }
    } else {
        msg = (void *)0;                         /* Queue is empty                                     */
    }
    OS_EXIT_CRITICAL();
    return (msg);                                /* Return message received (or NULL)                  */
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
*                                        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]
*
*              size          is the number of elements in the storage area
*
* 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  *OSQCreate (void **start, INT16U size)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif
    OS_EVENT  *pevent;
    OS_Q      *pq;


    if (OSIntNesting > 0) {                      /* See if called from ISR ...                         */
        return ((OS_EVENT *)0);                  /* ... can't CREATE from an ISR                       */
    }
    OS_ENTER_CRITICAL();
    pevent = OSEventFreeList;                    /* Get next free event control block                  */
    if (OSEventFreeList != (OS_EVENT *)0) {      /* See if pool of free ECB pool was empty             */
        OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
    }
    OS_EXIT_CRITICAL();
    if (pevent != (OS_EVENT *)0) {               /* See if we have an event control block              */
        OS_ENTER_CRITICAL();
        pq = OSQFreeList;                        /* Get a free queue control block                     */
        if (pq != (OS_Q *)0) {                   /* Were we able to get a queue control block ?        */
            OSQFreeList         = OSQFreeList->OSQPtr;    /* Yes, Adjust free list pointer to next free*/
            OS_EXIT_CRITICAL();
            pq->OSQStart        = start;                  /*      Initialize the queue                 */
            pq->OSQEnd          = &start[size];
            pq->OSQIn           = start;
            pq->OSQOut          = start;
            pq->OSQSize         = size;
            pq->OSQEntries      = 0;
            pevent->OSEventType = OS_EVENT_TYPE_Q;
            pevent->OSEventCnt  = 0;
            pevent->OSEventPtr  = pq;
            OS_EventWaitListInit(pevent);                 /*      Initalize the wait list              */
        } else {
            pevent->OSEventPtr = (void *)OSEventFreeList; /* No,  Return event control block on error  */
            OSEventFreeList    = pevent;
            OS_EXIT_CRITICAL();
            pevent = (OS_EVENT *)0;
        }
    }
    return (pevent);
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                        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.
*
*              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.
*
*              err           is a pointer to an error code that can contain one of the following values:
*                            OS_NO_ERR               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.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the queue was successfully deleted.
*
* 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.
*********************************************************************************************************
*/

#if OS_Q_DEL_EN > 0
OS_EVENT  *OSQDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif
    BOOLEAN    tasks_waiting;
    OS_Q      *pq;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return ((OS_EVENT *)0);
    }
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *err = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {          /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on queue        */
        tasks_waiting = TRUE;                              /* Yes                                      */
    } else {
        tasks_waiting = FALSE;                             /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete queue only if no task waiting     */
             if (tasks_waiting == FALSE) {
                 pq                  = (OS_Q *)pevent->OSEventPtr;  /* Return OS_Q to free list        */
                 pq->OSQPtr          = OSQFreeList;
                 OSQFreeList         = pq;
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 OSEventFreeList     = pevent;             /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *err = OS_NO_ERR;
                 return ((OS_EVENT *)0);                   /* Queue has been deleted                   */
             } else {
                 OS_EXIT_CRITICAL();
                 *err = OS_ERR_TASK_WAITING;
                 return (pevent);
             }

        case OS_DEL_ALWAYS:                                /* Always delete the queue                  */
             while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for queue        */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_Q);
             }
             pq                  = (OS_Q *)pevent->OSEventPtr;      /* Return OS_Q to free list        */
             pq->OSQPtr          = OSQFreeList;
             OSQFreeList         = pq;
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             OSEventFreeList     = pevent;                 /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err = OS_NO_ERR;
             return ((OS_EVENT *)0);                       /* Queue has been deleted                   */

        default:
             OS_EXIT_CRITICAL();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人动漫一区二区三区| 欧美性感一区二区三区| 日韩小视频在线观看专区| 欧美日韩在线播放一区| 久久久久国产精品厨房| 亚洲狠狠爱一区二区三区| 国产精品亚洲一区二区三区在线| 欧美影院一区二区| 国产精品国产三级国产三级人妇| 美女一区二区视频| 欧美日韩一级黄| 中文字幕一区二区三区四区| 国产又黄又大久久| 717成人午夜免费福利电影| 亚洲精品久久久久久国产精华液| 国产在线看一区| 日韩精品一区在线| 天堂一区二区在线免费观看| 欧美在线色视频| 亚洲欧美日韩国产综合在线| 不卡区在线中文字幕| 亚洲国产高清aⅴ视频| 久久国产精品免费| 欧美一级二级在线观看| 丝袜诱惑亚洲看片| 欧美二区乱c少妇| 亚洲高清免费一级二级三级| 在线欧美日韩精品| 亚洲精品国产精品乱码不99| 99久久精品国产导航| 国产精品美女一区二区| 成人晚上爱看视频| 国产精品看片你懂得| 波多野结衣一区二区三区| 国产精品久久777777| 暴力调教一区二区三区| 国产精品久久久久久福利一牛影视| 国产999精品久久久久久| 国产女人18毛片水真多成人如厕 | 色噜噜狠狠色综合中国 | 日韩欧美中文字幕公布| 美女视频免费一区| 亚洲精品中文在线| 91啪亚洲精品| 亚洲国产wwwccc36天堂| 欧美一区二区三区爱爱| 激情综合色综合久久综合| 国产午夜精品一区二区三区嫩草| 成人黄色在线视频| 亚洲精品国产视频| 欧美一级午夜免费电影| 国产精品一区二区在线播放| 国产精品九色蝌蚪自拍| 在线日韩国产精品| 九色综合国产一区二区三区| 国产三级欧美三级| 色狠狠一区二区| 蜜桃视频免费观看一区| 中文字幕不卡在线观看| 91国产免费观看| 蜜桃91丨九色丨蝌蚪91桃色| 国产精品你懂的在线| 欧美在线观看一二区| 六月丁香婷婷久久| 国产精品国模大尺度视频| 欧洲视频一区二区| 国产精品资源在线| 亚洲一区二区四区蜜桃| 欧美成人乱码一区二区三区| 成人av网址在线观看| 日韩不卡一区二区三区| 国产欧美一区二区三区网站| 久久精品水蜜桃av综合天堂| 一本一道综合狠狠老| 蜜桃视频一区二区| 亚洲精品免费视频| 国产欧美一区二区精品性| 欧美日韩一级二级三级| 成人av小说网| 黄页网站大全一区二区| 亚洲午夜私人影院| 国产精品美女久久福利网站| 欧美一区二区三区免费在线看| gogo大胆日本视频一区| 精品在线观看视频| 亚洲最新视频在线播放| 国产精品午夜久久| 日韩欧美在线1卡| 欧美在线免费播放| jlzzjlzz亚洲日本少妇| 国产精品一品视频| 日本中文在线一区| 亚洲国产精品视频| 亚洲视频中文字幕| 国产精品视频免费| 久久夜色精品国产噜噜av| 69堂成人精品免费视频| 欧美午夜精品理论片a级按摩| 夫妻av一区二区| 国产福利精品导航| 精彩视频一区二区| 蜜臀久久99精品久久久画质超高清 | 粉嫩av一区二区三区| 精品在线视频一区| 蜜桃视频在线观看一区二区| 丝袜亚洲另类欧美| 一区二区三区不卡视频在线观看| 国产精品午夜久久| 中文字幕第一区第二区| 国产欧美一区二区精品仙草咪| 精品国产91乱码一区二区三区 | 欧美精品一区二区久久婷婷| 91精品黄色片免费大全| 欧美日韩第一区日日骚| 在线观看欧美日本| 欧美日韩一区二区在线观看视频 | 国产乱码精品一区二区三| 久久精品国产亚洲高清剧情介绍| 日韩高清欧美激情| 蜜桃精品视频在线观看| 国内一区二区在线| 国产精品系列在线播放| 成人午夜又粗又硬又大| 成人黄页在线观看| 91色九色蝌蚪| 欧美色窝79yyyycom| 欧美日韩在线观看一区二区| 欧美精品99久久久**| 日韩一区二区视频| 久久免费电影网| 国产精品久久久久久久久动漫 | 在线免费亚洲电影| 在线不卡中文字幕| 精品国产91乱码一区二区三区| 国产婷婷色一区二区三区在线| 国产精品久久午夜| 亚洲综合一区在线| 美国欧美日韩国产在线播放| 国产福利精品一区二区| 欧美精品一区二区三区很污很色的 | 国产精品久久久久国产精品日日| 国产精品丝袜在线| 亚洲成人激情社区| 麻豆精品一区二区| 成人午夜视频免费看| 在线观看91精品国产入口| 欧美一区二区三区四区高清| 国产亚洲精品bt天堂精选| 国产精品电影一区二区| 日韩国产欧美视频| 国产成人免费视频一区| 欧美性xxxxxxxx| 欧美精品一区二区三区很污很色的 | 日韩国产精品91| 国产电影一区二区三区| 欧美色欧美亚洲另类二区| 精品国产乱子伦一区| 一区二区高清免费观看影视大全| 卡一卡二国产精品| 91在线观看地址| xfplay精品久久| 亚洲网友自拍偷拍| 丁香婷婷综合网| 日韩欧美第一区| 亚洲一区二区五区| 成人激情黄色小说| 精品国产区一区| 性做久久久久久久久| www.成人网.com| 久久久久久久精| 日韩av二区在线播放| 国产女人18毛片水真多成人如厕 | 极品少妇xxxx精品少妇偷拍| 色www精品视频在线观看| 久久久久久9999| 久久精品国产色蜜蜜麻豆| 在线视频一区二区三区| 中文字幕第一区综合| 久久激五月天综合精品| 欧美中文字幕一区二区三区 | 欧美一级午夜免费电影| 一区二区三区精品久久久| 丁香另类激情小说| 欧美xxxxxxxx| 免费欧美日韩国产三级电影| 欧美性xxxxx极品少妇| 成人欧美一区二区三区视频网页| 国产专区欧美精品| 精品免费视频.| 免费人成在线不卡| 欧美一级欧美三级在线观看| 亚洲线精品一区二区三区| 色欧美乱欧美15图片| 亚洲天堂av老司机| 97国产精品videossex| 国产精品美日韩| 不卡视频一二三| 亚洲视频免费观看| 91视频国产观看| 亚洲一卡二卡三卡四卡 |