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

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

?? os_q.c

?? 一步 移植ucosii for c51,ucosii for 51多任務實時操作系統
?? 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 "uCOS_II.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) OS_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
/*
*********************************************************************************************************
*                                        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_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);
}
/*
*********************************************************************************************************
*                                        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) OS_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:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线精品不卡| 99精品国产99久久久久久白柏| 国产乱码精品一区二区三区五月婷| 99精品欧美一区二区蜜桃免费| 欧美老人xxxx18| 中文字幕精品在线不卡| 青草av.久久免费一区| 在线视频你懂得一区二区三区| 欧美精品一区男女天堂| 亚洲不卡av一区二区三区| 亚洲图片欧美视频| 日韩精品视频网| 91老师片黄在线观看| 国产视频一区二区在线| 激情另类小说区图片区视频区| 欧美一区二区三区免费视频| 综合亚洲深深色噜噜狠狠网站| 精品一区二区免费在线观看| 欧美日韩日日夜夜| 亚洲与欧洲av电影| 色综合天天综合网天天狠天天| 国产肉丝袜一区二区| 精一区二区三区| 日韩欧美一区二区免费| 亚洲福利视频导航| 欧美日韩午夜在线| 亚洲成a人v欧美综合天堂下载| 在线视频国内一区二区| 一区二区三区中文在线| 欧美中文字幕一二三区视频| 一区二区三区免费看视频| 色婷婷亚洲婷婷| 亚洲一区视频在线观看视频| 在线精品观看国产| 亚欧色一区w666天堂| 欧美亚洲禁片免费| 午夜精品视频在线观看| 欧美精品18+| 麻豆专区一区二区三区四区五区| 日韩欧美中文一区| 狠狠色丁香婷婷综合久久片| 久久久久九九视频| 97精品久久久久中文字幕| 一区二区成人在线| 欧美性猛交xxxx乱大交退制版 | 国产三级三级三级精品8ⅰ区| 免费高清在线视频一区·| 欧美成人女星排名| 国产麻豆午夜三级精品| 国产精品免费丝袜| 欧美丝袜自拍制服另类| 国产盗摄女厕一区二区三区| 国产精品久久一卡二卡| 欧美亚洲日本一区| 韩国三级在线一区| 亚洲桃色在线一区| 91精品国产色综合久久不卡蜜臀| 韩国精品主播一区二区在线观看 | 色欧美88888久久久久久影院| 一区二区三区四区在线免费观看 | 丝袜亚洲另类欧美| 久久网这里都是精品| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲摸摸操操av| 日韩午夜精品视频| 成人晚上爱看视频| 男女男精品视频网| **性色生活片久久毛片| 日韩一区二区中文字幕| 99久久综合精品| 免费成人av在线播放| 亚洲视频一二三| 欧美成人一区二区三区| 色综合色综合色综合色综合色综合| 婷婷六月综合亚洲| 亚洲视频一区在线观看| 久久综合一区二区| 欧美乱熟臀69xxxxxx| 成人激情动漫在线观看| 日本欧美加勒比视频| 亚洲欧美在线另类| www国产精品av| 欧美日韩激情在线| 91丨九色丨蝌蚪富婆spa| 国产最新精品免费| 麻豆一区二区99久久久久| 又紧又大又爽精品一区二区| 国产亚洲精品bt天堂精选| 欧美日本高清视频在线观看| 色综合久久久久综合体| 成人听书哪个软件好| 韩国三级电影一区二区| 日本网站在线观看一区二区三区 | 麻豆国产精品视频| 久久精品国产精品亚洲精品 | 国产日韩三级在线| 在线成人午夜影院| 在线观看一区不卡| 99国产欧美另类久久久精品| 国产精品一区二区无线| 激情久久久久久久久久久久久久久久| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲国产精品传媒在线观看| 久久久天堂av| 日韩免费高清电影| 日韩写真欧美这视频| 欧美一级淫片007| 亚洲免费在线播放| 26uuu国产电影一区二区| 欧美一级高清大全免费观看| 欧美日韩一级视频| 欧美私模裸体表演在线观看| 91成人看片片| 欧美影片第一页| 欧美日韩视频在线第一区 | 国产乱一区二区| 久久成人精品无人区| 看电影不卡的网站| 麻豆国产精品一区二区三区| 精品一区二区三区的国产在线播放| 蜜桃一区二区三区四区| 久久99精品久久久久久动态图 | 国产欧美精品一区| 中文在线一区二区| 中文字幕在线不卡一区| 亚洲精品欧美激情| 日韩午夜激情免费电影| 亚洲v精品v日韩v欧美v专区| 亚洲国产美国国产综合一区二区| 亚洲午夜激情网站| 日韩成人午夜精品| 国产一区二区影院| 春色校园综合激情亚洲| 97精品久久久久中文字幕 | 日韩一区二区影院| 国产女人水真多18毛片18精品视频| 国产欧美日韩三区| 亚洲激情在线激情| 日韩综合在线视频| 国产一区999| 色悠悠久久综合| 欧美一区日韩一区| 欧美经典一区二区| 亚洲国产精品综合小说图片区| 老司机精品视频线观看86| 成人免费电影视频| 欧美日本在线观看| 国产午夜精品久久久久久免费视| 日韩理论片在线| 美女视频黄 久久| 不卡一区二区三区四区| 91丝袜国产在线播放| 亚洲va欧美va人人爽午夜| 日本成人在线不卡视频| 国产精品一区一区| 欧美日韩高清一区| 亚洲国产精品高清| 秋霞电影一区二区| 91麻豆国产精品久久| 日韩精品中文字幕在线一区| 亚洲三级在线免费| 国内精品视频一区二区三区八戒| 色综合中文字幕国产| 欧美日韩高清在线播放| 国产精品情趣视频| 不卡一区二区三区四区| 日韩一区国产二区欧美三区| 亚洲免费观看高清完整版在线| 久久精品国产成人一区二区三区| 日本韩国欧美在线| 国产精品人妖ts系列视频| 免费成人小视频| 91成人在线精品| 亚洲欧美一区二区视频| 国产一区高清在线| 欧美一区二区三区四区五区| 自拍偷在线精品自拍偷无码专区| 国产主播一区二区三区| 欧美片网站yy| 国产精品毛片久久久久久久| 美国av一区二区| 色av一区二区| 中文字幕欧美激情| 国产一区二区三区免费在线观看| 制服丝袜中文字幕亚洲| 亚洲一区二区三区影院| 91免费看片在线观看| 中文字幕av一区二区三区免费看| 九一九一国产精品| 91精品久久久久久蜜臀| 五月婷婷激情综合网| 色综合夜色一区| 日韩毛片精品高清免费| 91麻豆福利精品推荐| 中文字幕视频一区二区三区久| 成人免费视频视频| 国产精品电影一区二区三区| 99久久国产综合精品女不卡| 亚洲人亚洲人成电影网站色| 91免费观看国产|