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

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

?? os_q.c

?? 51單片機上移植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)LG_REENTRANT
{
#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)LG_REENTRANT
{
#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)LG_REENTRANT
{
#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一区二区三区免费野_久草精品视频
久久99国内精品| 亚洲视频一区二区在线| 久久先锋影音av鲁色资源网| 国产欧美一区二区三区鸳鸯浴| 成人免费一区二区三区在线观看| 亚洲电影在线播放| 精品一区二区三区日韩| 波波电影院一区二区三区| 精品视频999| 精品对白一区国产伦| 亚洲视频一区二区免费在线观看| 午夜av一区二区| 国产福利电影一区二区三区| 在线精品视频免费观看| 欧美videossexotv100| 中文字幕中文乱码欧美一区二区 | 久久精品国产久精国产爱| 国产91在线观看丝袜| 欧美日韩一区二区三区高清| 久久久精品黄色| 一区二区三区不卡在线观看| 国产真实精品久久二三区| 色网综合在线观看| 久久亚洲春色中文字幕久久久| 亚洲欧美日韩成人高清在线一区| 久久国产精品色| 色狠狠综合天天综合综合| 久久亚洲精精品中文字幕早川悠里| 洋洋成人永久网站入口| 国产一区二区三区| 欧美人妇做爰xxxⅹ性高电影| 国产精品视频九色porn| 奇米色777欧美一区二区| 91麻豆精品在线观看| 久久综合国产精品| 日本亚洲最大的色成网站www| 色综合中文综合网| 91麻豆精品国产自产在线观看一区| 中文字幕免费不卡| 老司机免费视频一区二区| 91福利视频久久久久| 久久精品视频一区二区三区| 蜜臀久久99精品久久久久宅男 | 天堂一区二区在线免费观看| 成人av网站在线| 久久久综合精品| 麻豆91在线观看| 欧美日韩另类一区| 亚洲一区二区影院| 色综合久久66| 亚洲免费在线播放| 成人综合日日夜夜| 国产日产精品一区| 日韩精品最新网址| 国产91丝袜在线观看| 亚洲成a人v欧美综合天堂 | 国产一区二区三区| 7777精品伊人久久久大香线蕉超级流畅 | 91精品国产欧美日韩| 精品视频1区2区| 欧美日韩大陆一区二区| 91精品国产乱码| 成人sese在线| 国产亚洲欧美在线| 色哟哟在线观看一区二区三区| 国产日韩欧美精品综合| 成人高清伦理免费影院在线观看| 一本大道久久a久久精二百| 三级不卡在线观看| 在线播放91灌醉迷j高跟美女 | 亚洲色图清纯唯美| 成人一区在线看| 亚洲免费伊人电影| www.日韩在线| 亚洲欧洲日韩av| 91麻豆.com| 日一区二区三区| 欧美日韩在线一区二区| 亚洲午夜一区二区| 欧美人牲a欧美精品| 国产精品一区一区三区| 91精品国产乱码久久蜜臀| 国产在线日韩欧美| 中文字幕的久久| 欧美日韩专区在线| 激情五月婷婷综合网| 国产精品对白交换视频 | 蜜芽一区二区三区| 欧美一区二区三区在线观看视频| 国产69精品久久久久毛片| **性色生活片久久毛片| 亚洲免费三区一区二区| 亚洲一区二区三区四区五区黄| 在线视频一区二区三区| 一区二区在线免费| 欧美精品一级二级| 狠狠色狠狠色综合系列| 国产日韩综合av| 99国产精品国产精品久久| 亚洲免费视频成人| 欧美一区二区免费视频| 国产露脸91国语对白| 亚洲欧洲精品成人久久奇米网| 在线中文字幕不卡| 蜜桃视频第一区免费观看| 久久久不卡网国产精品一区| av影院午夜一区| 亚洲gay无套男同| 久久色在线视频| 色综合久久中文字幕综合网| 五月婷婷久久丁香| 26uuu亚洲综合色欧美 | 久久综合色婷婷| 91一区二区三区在线观看| 亚洲成人福利片| 久久久www免费人成精品| 色综合久久久久综合99| 蜜桃av噜噜一区| 亚洲欧洲日韩女同| 日韩欧美一区二区不卡| 99re这里都是精品| 青青草精品视频| 1024成人网| 日韩精品一区二区三区四区| 99精品视频在线观看免费| 美女国产一区二区| 亚洲欧美日韩中文字幕一区二区三区| 91精品国产乱码久久蜜臀| 99在线精品免费| 麻豆精品久久久| 亚洲精品写真福利| 久久色在线视频| 制服丝袜激情欧洲亚洲| av中文一区二区三区| 久久99久久久久| 亚洲一区二区在线免费观看视频| 国产欧美精品区一区二区三区 | 日本v片在线高清不卡在线观看| 国产精品丝袜黑色高跟| 欧美一区二区日韩一区二区| 色婷婷综合激情| 成人精品高清在线| 韩国av一区二区三区在线观看| 亚洲一级电影视频| 亚洲色图欧美偷拍| 欧美国产欧美综合| 精品国产百合女同互慰| 欧美三级欧美一级| av电影在线观看一区| 国产精品一区在线观看你懂的| 天天色图综合网| 一区二区三区欧美亚洲| 国产精品久久久久aaaa樱花 | 成人精品免费看| 激情五月激情综合网| 日韩av电影天堂| 亚洲国产中文字幕在线视频综合| 国产精品三级av| 国产午夜精品一区二区三区四区| 欧美成人精品1314www| 欧美日本在线播放| 欧美色综合天天久久综合精品| 99re这里只有精品首页| 成人开心网精品视频| 粉嫩欧美一区二区三区高清影视| 久久9热精品视频| 免费一级片91| 免费成人结看片| 婷婷一区二区三区| 亚洲成av人片| 亚洲va韩国va欧美va精品| 亚洲一卡二卡三卡四卡| 亚洲国产va精品久久久不卡综合 | 欧美乱妇一区二区三区不卡视频| 日本道色综合久久| 色94色欧美sute亚洲13| 99热99精品| 99re视频精品| 91无套直看片红桃| 91老司机福利 在线| 91香蕉视频mp4| 色婷婷综合五月| 欧美色图一区二区三区| 欧美性做爰猛烈叫床潮| 欧美美女一区二区在线观看| 欧美精品久久久久久久久老牛影院| 欧美日本一区二区在线观看| 在线播放中文字幕一区| 欧美成人在线直播| 久久综合视频网| 日本一区二区久久| 中文字幕在线观看不卡| 亚洲免费在线观看| 亚洲第一电影网| 蜜臀va亚洲va欧美va天堂| 国产一区二区美女诱惑| 成人性生交大片免费看中文网站| 成人国产精品免费| 欧日韩精品视频| 91精品婷婷国产综合久久性色|