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

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

?? os_q.c

?? UCosII 的完整源代碼
?? 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一区二区三区免费野_久草精品视频
在线观看国产精品网站| 欧美三级资源在线| 午夜精品福利一区二区三区av| 日韩午夜在线观看| eeuss鲁片一区二区三区在线观看| 依依成人精品视频| 久久婷婷国产综合国色天香| 欧美综合一区二区三区| 国产精品一区二区免费不卡| 视频一区二区三区入口| 亚洲天堂成人在线观看| 亚洲在线观看免费| 亚洲欧洲日韩综合一区二区| 欧美mv日韩mv国产网站| 欧美日韩综合不卡| jlzzjlzz国产精品久久| 国产精品综合在线视频| 日韩一区精品字幕| 一区二区三区美女视频| 亚洲少妇屁股交4| 中文字幕国产一区| 精品久久免费看| 欧美一二三区在线观看| 欧美欧美午夜aⅴ在线观看| 91麻豆123| av一区二区三区在线| 国产a视频精品免费观看| 免费观看久久久4p| 日韩电影在线观看电影| 一区二区免费视频| 亚洲精选免费视频| 亚洲人成在线观看一区二区| 中文字幕一区二区三区在线播放| 国产欧美日韩在线看| 久久精品无码一区二区三区| 久久久天堂av| 久久综合给合久久狠狠狠97色69| 91精品婷婷国产综合久久| 欧美乱妇一区二区三区不卡视频| 欧美三级乱人伦电影| 在线观看日韩国产| 欧美视频一区二区三区四区| 在线精品视频小说1| 91福利在线免费观看| 欧美在线看片a免费观看| 在线观看日韩毛片| 在线播放日韩导航| 欧美一卡2卡三卡4卡5免费| 欧美一级二级三级蜜桃| 日韩欧美久久一区| 久久精品一区二区| 国产精品每日更新| 伊人开心综合网| 午夜精品久久一牛影视| 日韩和欧美一区二区| 麻豆久久久久久| 国产乱子伦视频一区二区三区| 国产精品538一区二区在线| 成人网男人的天堂| 色美美综合视频| 欧美一区中文字幕| 国产亚洲欧美日韩日本| 最新热久久免费视频| 亚洲电影在线播放| 蜜乳av一区二区三区| 国产麻豆精品久久一二三| av资源站一区| 欧美日韩高清一区二区| 久久女同互慰一区二区三区| 亚洲视频1区2区| 欧美精品一区二区三区高清aⅴ| 日韩精品一区二区三区蜜臀| 久久久久一区二区三区四区| 日韩av一区二区三区四区| 婷婷六月综合网| 成人国产在线观看| 色吧成人激情小说| 69堂精品视频| 亚洲国产高清在线观看视频| 国产精品福利一区二区| 亚洲已满18点击进入久久| 日韩成人dvd| 一区二区三区日韩精品视频| 亚洲无人区一区| 国产一区二区按摩在线观看| 色综合一区二区三区| 91精品国产色综合久久不卡蜜臀 | 国产最新精品免费| 99视频国产精品| 日韩欧美精品在线视频| 亚洲男人电影天堂| 国产一区视频导航| 欧美日韩激情一区| 最好看的中文字幕久久| 韩国三级电影一区二区| 在线看国产一区| 国产精品无圣光一区二区| 男男成人高潮片免费网站| 色综合一区二区| 国产色一区二区| 久久国产欧美日韩精品| 一本色道亚洲精品aⅴ| 久久久综合激的五月天| 日韩激情av在线| 欧美最猛黑人xxxxx猛交| 中文字幕不卡在线| 国产米奇在线777精品观看| 欧美日韩在线电影| 一区二区三区日韩精品| 成人免费电影视频| 久久精品人人爽人人爽| 欧美a一区二区| 欧美性色欧美a在线播放| 国产精品毛片高清在线完整版 | 亚洲国产毛片aaaaa无费看| 成人毛片在线观看| 久久影院午夜片一区| 免费高清不卡av| 欧美主播一区二区三区| 1024成人网| 99久久er热在这里只有精品66| 26uuu国产日韩综合| 麻豆精品蜜桃视频网站| 91麻豆精品国产无毒不卡在线观看| 一区二区三区成人在线视频| aaa亚洲精品| 国产精品久久久久久久久晋中| 国产成人一区在线| 国产网站一区二区| 国产精品一区二区不卡| 色av一区二区| 亚洲久草在线视频| 国产精品免费观看视频| 欧美日韩国产经典色站一区二区三区| 国产精品77777竹菊影视小说| 精品国产免费人成电影在线观看四季 | 亚洲国产综合色| 麻豆成人在线观看| 日韩精品一区二区三区四区 | 不卡的av中国片| 国产精品免费av| 99精品国产视频| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 国产91综合网| 国产精品狼人久久影院观看方式| 99热在这里有精品免费| 亚洲日本韩国一区| 在线观看免费亚洲| 三级不卡在线观看| 日韩免费视频一区二区| 国内精品久久久久影院色| 久久精品免视看| 91色在线porny| 亚洲大片在线观看| 日韩免费看网站| 国内外精品视频| 欧美三级视频在线观看 | 国产精品一区二区在线观看不卡 | 精品婷婷伊人一区三区三| 亚洲观看高清完整版在线观看| 欧美日韩综合在线| 老司机免费视频一区二区三区| 久久久精品国产99久久精品芒果 | 麻豆成人91精品二区三区| 国产午夜精品久久久久久免费视| 91在线云播放| 午夜视频一区二区三区| 日韩精品一区二区三区四区 | 亚洲第一福利视频在线| 日韩欧美电影一区| 99热这里都是精品| 青青草原综合久久大伊人精品 | 国模大尺度一区二区三区| 成人午夜av电影| 欧美亚洲另类激情小说| 在线视频观看一区| 欧美日韩成人综合在线一区二区| 色女孩综合影院| 亚洲色图制服诱惑 | 中文字幕日本乱码精品影院| 久久老女人爱爱| 亚洲欧美精品午睡沙发| 亚洲精品中文字幕在线观看| 亚洲蜜臀av乱码久久精品蜜桃| 97精品久久久午夜一区二区三区| 三级精品在线观看| 久久综合色婷婷| 99re视频精品| 美女www一区二区| 日韩理论电影院| 久久蜜桃av一区二区天堂| 色噜噜久久综合| 久久99精品网久久| 亚洲国产精品自拍| 中文字幕亚洲不卡| 欧美va亚洲va香蕉在线| 欧美日韩综合一区| 99v久久综合狠狠综合久久| 欧美96一区二区免费视频| 成人免费在线视频观看|