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

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

?? os_q.c

?? 這是我買uCOS-II第二版本書帶的光盤的資料
?? 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一区二区三区免费野_久草精品视频
91.麻豆视频| 日韩欧美一区中文| 国产白丝精品91爽爽久久| 日韩av电影免费观看高清完整版| 一区二区三区鲁丝不卡| 亚洲黄色在线视频| 五月天欧美精品| 日韩av不卡一区二区| 奇米777欧美一区二区| 免费在线看成人av| 国产一区二区在线免费观看| 国产精品 欧美精品| 91网站视频在线观看| 欧美日韩在线观看一区二区 | 免费看日韩精品| 六月丁香综合在线视频| 欧美大肚乱孕交hd孕妇| 国产三级久久久| 国产精品素人视频| 亚洲精品视频免费看| 亚洲成人手机在线| 美女脱光内衣内裤视频久久网站 | 欧美色网站导航| 欧美精品日韩综合在线| 久久综合久久综合久久综合| 国产精品第一页第二页第三页| 一区二区免费视频| 久久超碰97中文字幕| a在线播放不卡| 91精品国产色综合久久ai换脸| www国产成人| 亚洲在线成人精品| 国产福利精品导航| 91精品国产日韩91久久久久久| 久久久精品黄色| 亚洲成人手机在线| av中文字幕一区| 欧美一区二区免费| 亚洲精品va在线观看| 国内不卡的二区三区中文字幕 | 一区二区三区四区激情| 精品无人区卡一卡二卡三乱码免费卡| 成人禁用看黄a在线| 欧美二区三区91| 亚洲人成小说网站色在线| 麻豆91在线播放免费| 色老头久久综合| 国产精品成人午夜| 国产在线播精品第三| 91精品国产品国语在线不卡| 亚洲欧美日韩一区| 成人免费高清视频在线观看| 精品福利二区三区| 日本不卡中文字幕| 欧美日韩一区二区三区在线看| 国产精品福利影院| 成人免费视频视频| 欧美激情中文字幕| 国产**成人网毛片九色| 精品动漫一区二区三区在线观看| 亚洲国产毛片aaaaa无费看| 91网上在线视频| 亚洲欧美一区二区三区孕妇| 成人黄色软件下载| 国产日韩高清在线| 国产在线精品一区二区| 久久这里只有精品视频网| 久久国产剧场电影| 精品国产污网站| 九九精品一区二区| 精品国产百合女同互慰| 国产精品亚洲一区二区三区妖精| 日韩视频免费观看高清完整版在线观看 | 欧美浪妇xxxx高跟鞋交| 亚洲视频在线观看一区| www.视频一区| 亚洲男人的天堂网| 在线视频你懂得一区二区三区| 亚洲品质自拍视频网站| 色国产综合视频| 亚洲午夜久久久久中文字幕久| 在线一区二区观看| 午夜不卡av免费| 欧美男同性恋视频网站| 五月天丁香久久| 欧美一区二区视频在线观看2022 | 精品视频一区三区九区| 一级做a爱片久久| 制服丝袜国产精品| 美日韩一区二区三区| 91精品国产高清一区二区三区| 麻豆精品国产91久久久久久| 久久久久国产精品免费免费搜索| 国产99久久久久久免费看农村| 国产精品久久久久9999吃药| 欧美丝袜丝交足nylons图片| 午夜免费欧美电影| 精品日产卡一卡二卡麻豆| 韩国三级电影一区二区| 最新日韩在线视频| 884aa四虎影成人精品一区| 国产在线精品一区二区夜色 | 亚洲成人综合网站| 久久综合网色—综合色88| eeuss国产一区二区三区| 亚洲一区二区四区蜜桃| 日韩欧美国产成人一区二区| 成人免费视频一区| 日韩电影在线观看一区| 国产精品亲子伦对白| 欧美伊人精品成人久久综合97 | 亚洲一区二区欧美激情| 欧美变态tickling挠脚心| 成人午夜av电影| 日产国产欧美视频一区精品| 国产精品国产三级国产普通话99| 欧美精品欧美精品系列| 国产成人av影院| 日韩va欧美va亚洲va久久| 亚洲三级电影网站| 久久影院视频免费| 欧美精品久久久久久久多人混战 | 日本伊人午夜精品| 亚洲另类在线一区| 国产亚洲精品aa午夜观看| 欧美区在线观看| 日本福利一区二区| 粉嫩av亚洲一区二区图片| 日本在线不卡视频| 亚洲最快最全在线视频| 国产性天天综合网| 欧美成人video| 日韩一区二区在线看| 欧美日韩不卡一区| 91国偷自产一区二区三区成为亚洲经典| 精品一区精品二区高清| 日韩va欧美va亚洲va久久| 亚洲一区二区三区四区不卡| 日韩理论片中文av| 亚洲欧洲性图库| 国产精品视频一二| 日本一区二区动态图| 国产区在线观看成人精品| 日韩欧美一区在线| 精品国产免费视频| 精品免费99久久| 精品福利一二区| 久久久久久免费| 久久久久国产精品人| 久久久精品tv| 欧美激情自拍偷拍| 国产精品视频在线看| 久久精品亚洲乱码伦伦中文| 久久久一区二区三区捆绑**| 国产欧美一区二区精品久导航 | 麻豆成人久久精品二区三区红 | 国产综合久久久久久鬼色| 蜜桃一区二区三区在线观看| 天使萌一区二区三区免费观看| 亚洲二区在线视频| 日韩激情一区二区| 九色porny丨国产精品| 黄色小说综合网站| jlzzjlzz欧美大全| 91成人免费在线| 日韩一级片在线播放| 久久夜色精品一区| 国产精品久久久久婷婷二区次| 亚洲精品免费视频| 亚洲成人你懂的| 国内成+人亚洲+欧美+综合在线| 成人国产精品免费| 欧美日韩在线一区二区| 久久午夜电影网| 综合色中文字幕| 亚洲国产一区二区视频| www.成人网.com| 欧美日韩高清一区| 亚洲精品在线电影| 中文字幕日本不卡| 亚州成人在线电影| 国产高清成人在线| 欧美色综合网站| 国产日本一区二区| 午夜精品久久久久久久久久久| 国产一区视频在线看| 99r国产精品| 欧美成人女星排名| 亚洲人精品一区| 国产一区 二区| 欧美日韩中文另类| 亚洲欧洲av在线| 激情综合亚洲精品| 在线观看亚洲一区| 国产欧美综合在线观看第十页| 亚洲国产精品视频| av激情成人网| 欧美韩日一区二区三区四区| 日韩国产欧美在线播放| 91在线porny国产在线看|