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

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

?? os_q.c

?? 在W78E58處理器上移植的uCOS-
?? 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)
{

    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)
{

    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)
{

    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一区二区三区免费野_久草精品视频
热久久一区二区| 日本不卡123| 国产欧美精品在线观看| 亚洲精品一区二区在线观看| 日韩一级片网站| 欧美不卡一二三| 精品成人一区二区三区| 26uuu国产在线精品一区二区| 精品国产一区二区三区久久久蜜月| 欧美精品九九99久久| 欧美一级夜夜爽| 精品国产人成亚洲区| 日本一区二区三级电影在线观看 | 国产日韩欧美在线一区| 久久久不卡网国产精品二区| 久久精品在这里| 亚洲少妇30p| 午夜亚洲福利老司机| 奇米影视在线99精品| 国产一区二区三区四区五区入口| 三级欧美韩日大片在线看| 极品瑜伽女神91| 91丨九色丨尤物| 欧美酷刑日本凌虐凌虐| 精品少妇一区二区三区| 欧美激情在线一区二区三区| 中文字幕亚洲成人| 日本人妖一区二区| 成年人网站91| 欧美一级一级性生活免费录像| 精品成a人在线观看| 一区在线观看视频| 欧美a级一区二区| a级精品国产片在线观看| 欧美日韩亚洲高清一区二区| 久久精品一级爱片| 亚洲18色成人| www.在线成人| 日韩三级伦理片妻子的秘密按摩| 国产精品久久久一区麻豆最新章节| 亚洲午夜免费福利视频| 国产精品88888| 欧美高清视频www夜色资源网| 久久综合久久综合久久综合| 五月综合激情日本mⅴ| 国产精品1区二区.| 欧美一区中文字幕| 一区二区三区在线免费播放| 国产精品一区专区| 日韩三级.com| 一卡二卡欧美日韩| 成人h精品动漫一区二区三区| 9191成人精品久久| 亚洲自拍偷拍综合| 91捆绑美女网站| 中文字幕一区二区在线观看| 国产一区二区美女诱惑| 欧美一区二区成人6969| 又紧又大又爽精品一区二区| av在线这里只有精品| 国产三级一区二区| 国产精品亚洲а∨天堂免在线| 日韩一卡二卡三卡| 美国三级日本三级久久99| 色婷婷狠狠综合| 一区二区三区日本| 91蜜桃视频在线| 亚洲激情av在线| 一本一道久久a久久精品综合蜜臀| 国产精品三级av在线播放| 国产成人免费在线| 久久精品日韩一区二区三区| 国产经典欧美精品| 欧美国产成人在线| av欧美精品.com| 亚洲精品免费在线观看| 色狠狠色噜噜噜综合网| 亚洲精品欧美专区| 欧美日韩精品一区二区在线播放| 亚洲资源中文字幕| 欧美日韩二区三区| 麻豆精品蜜桃视频网站| 久久亚洲精精品中文字幕早川悠里 | 日韩伦理av电影| 色综合久久天天综合网| 亚洲永久免费视频| 91精品国产福利| 国产99久久精品| 亚洲女人的天堂| 91精品国产一区二区三区蜜臀| 日韩有码一区二区三区| 精品福利一二区| aaa欧美大片| 亚洲地区一二三色| 久久久亚洲国产美女国产盗摄| 国产剧情在线观看一区二区| 日本一区二区高清| 日本道色综合久久| 日韩精品亚洲专区| 精品福利一二区| 成人激情动漫在线观看| 亚洲视频一区在线| 欧美一二三四在线| 成人一级视频在线观看| 夜色激情一区二区| 久久先锋影音av鲁色资源 | 国产欧美日韩另类一区| 色狠狠色狠狠综合| 国产精品一区二区久久精品爱涩| 亚洲欧美另类小说视频| 日韩欧美视频一区| 91啪九色porn原创视频在线观看| 麻豆精品在线看| 亚洲乱码中文字幕综合| 日韩美女视频在线| 91网站最新地址| 国产精品一区二区在线观看网站| 亚洲午夜成aⅴ人片| 国产婷婷色一区二区三区| 欧美高清视频不卡网| 99国产欧美另类久久久精品| 另类综合日韩欧美亚洲| 亚洲制服丝袜在线| 亚洲欧美一区二区视频| 欧美精品一区二区三区四区| 在线91免费看| 在线观看免费成人| 97se亚洲国产综合自在线| 极品销魂美女一区二区三区| 亚洲成人黄色小说| 亚洲激情综合网| 亚洲人亚洲人成电影网站色| 日韩一区二区视频| 51精品秘密在线观看| 在线观看日韩av先锋影音电影院| 成人福利视频网站| 成人动漫视频在线| 成人听书哪个软件好| 精品中文字幕一区二区| 久久成人18免费观看| 蜜芽一区二区三区| 国产河南妇女毛片精品久久久| 五月婷婷激情综合网| 亚洲香肠在线观看| 一二三四社区欧美黄| 亚洲图片激情小说| 亚洲另类春色校园小说| 亚洲欧美影音先锋| 亚洲精品乱码久久久久久黑人| 最近日韩中文字幕| 亚洲猫色日本管| 亚洲精选视频免费看| 亚洲激情中文1区| 亚洲成人激情社区| 日韩激情在线观看| 久久99久久精品欧美| 国内成+人亚洲+欧美+综合在线| 美女视频黄 久久| 国产在线不卡一区| 成人一级黄色片| 99国产精品久久| 精品视频在线视频| 3d动漫精品啪啪一区二区竹菊| 欧美区在线观看| www国产成人免费观看视频 深夜成人网 | 亚洲精品水蜜桃| 午夜av电影一区| 国产毛片一区二区| 成人性生交大片| 91久久人澡人人添人人爽欧美| 欧美日韩一区二区电影| 日韩欧美一级在线播放| 国产精品91xxx| 91国模大尺度私拍在线视频| 不卡在线视频中文字幕| 日本高清不卡视频| 欧美成人三级在线| |精品福利一区二区三区| 亚洲午夜精品久久久久久久久| 日韩影视精彩在线| 国产成a人亚洲精品| 日本高清不卡在线观看| 日韩欧美一级特黄在线播放| 国产精品色呦呦| 婷婷六月综合网| 成人美女视频在线观看18| 欧美日韩在线亚洲一区蜜芽| 欧美电影免费观看高清完整版在线 | 亚洲视频小说图片| 日韩av高清在线观看| 成人国产精品免费观看动漫| 欧美日韩在线播放| 国产日产精品1区| 首页综合国产亚洲丝袜| 国产成人在线观看| 欧美日韩国产另类不卡| 国产欧美久久久精品影院| 天天射综合影视| 色综合天天天天做夜夜夜夜做| 欧美一区二区精品久久911|