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

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

?? os_q.c

?? uCosII 郵箱消息和任務管理
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                        MESSAGE QUEUE MANAGEMENT
*
*                          (c) Copyright 1992-2001, 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();                     /* Get a free queue control block                     */
        pq = OSQFreeList;
        if (OSQFreeList != (OS_Q *)0) {
            OSQFreeList = OSQFreeList->OSQPtr;
        }
        OS_EXIT_CRITICAL();
        if (pq != (OS_Q *)0) {                   /* See if we were able to get a queue control block   */
            pq->OSQStart        = start;         /* Yes, 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->OSEventPtr  = pq;
            OS_EventWaitListInit(pevent);
        } else {                                 /* No,  since we couldn't get a queue control block   */
            OS_ENTER_CRITICAL();                 /* Return event control block on error                */
            pevent->OSEventPtr = (void *)OSEventFreeList;
            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                  = 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                  = 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一区二区三区免费野_久草精品视频
一区二区三区国产| 亚洲视频香蕉人妖| 欧美日韩视频在线第一区| 成人精品一区二区三区中文字幕| 久久er99精品| 免费观看在线色综合| 美女脱光内衣内裤视频久久网站| 亚洲福利一二三区| 日韩高清一区在线| 日本不卡中文字幕| 日本特黄久久久高潮| 综合中文字幕亚洲| 麻豆91在线播放免费| 一区二区三区欧美亚洲| 亚洲人成7777| 亚洲大片免费看| 亚洲va欧美va天堂v国产综合| 亚洲电影第三页| 秋霞午夜鲁丝一区二区老狼| 国产真实乱对白精彩久久| 亚洲伦理在线精品| 亚洲欧洲精品一区二区三区 | 国产精品久久影院| 亚洲欧美另类在线| 午夜欧美视频在线观看| 精品一二三四区| 成人高清视频在线观看| 欧美亚洲图片小说| 日韩一区二区三| 国产亚洲一本大道中文在线| 亚洲精品高清视频在线观看| 青娱乐精品在线视频| 成人性生交大片免费看视频在线| 色婷婷av一区二区三区gif| 欧美日韩不卡一区二区| 久久精品人人做| 亚洲美女免费在线| 久久精品国产秦先生| 91在线视频观看| 欧美岛国在线观看| 一区二区三区精品在线| 精品一区二区三区视频在线观看| 91一区二区在线| 欧美zozo另类异族| 亚洲国产成人精品视频| 国产毛片精品视频| 欧美日本韩国一区| 国产亚洲婷婷免费| 日韩av一级电影| 色婷婷综合在线| 久久伊99综合婷婷久久伊| 亚洲网友自拍偷拍| kk眼镜猥琐国模调教系列一区二区| 欧美军同video69gay| 国产精品视频观看| 精品一二线国产| 欧美精品第1页| 亚洲精品一二三| 懂色av中文一区二区三区| 欧美日韩二区三区| 最新欧美精品一区二区三区| 久久99国产精品麻豆| 在线观看国产精品网站| 成人欧美一区二区三区1314| 韩国女主播成人在线观看| 欧美日韩久久久| 日韩理论片在线| 国产精品一区免费视频| 欧美成人video| 56国语精品自产拍在线观看| 国产精品免费aⅴ片在线观看| 日韩高清不卡在线| 欧美三级一区二区| 中文字幕一区二区在线播放 | 中文字幕制服丝袜成人av| 午夜精品视频一区| 色综合中文字幕国产| 精品国产乱码久久久久久久久| 亚洲少妇屁股交4| 国内精品伊人久久久久av影院 | 一个色在线综合| 国产精品一级在线| 日韩一卡二卡三卡国产欧美| 亚洲第一主播视频| 欧美午夜视频网站| 一区二区在线电影| 在线观看亚洲一区| 亚洲高清免费观看| 91精品福利在线| 亚洲美女偷拍久久| jiyouzz国产精品久久| 中文字幕不卡三区| 国产精品888| 日韩欧美aaaaaa| 久久精品国产**网站演员| 欧美美女网站色| 亚洲精品欧美在线| 欧美日韩精品一区二区天天拍小说| 亚洲成av人片在www色猫咪| 欧美天堂一区二区三区| 亚洲综合一区二区| 色国产综合视频| 亚洲免费观看高清完整版在线| 不卡av免费在线观看| 国产精品毛片久久久久久| a亚洲天堂av| 国产精品妹子av| 色综合天天狠狠| 亚洲宅男天堂在线观看无病毒| 欧美亚洲免费在线一区| 一卡二卡欧美日韩| 欧美午夜免费电影| 日一区二区三区| 日韩欧美成人午夜| 国产99精品国产| 亚洲女爱视频在线| 欧美日韩国产美女| 激情小说欧美图片| 久久久午夜精品理论片中文字幕| 国产精品77777竹菊影视小说| 亚洲码国产岛国毛片在线| 欧美唯美清纯偷拍| 国内精品在线播放| 亚洲欧美日韩小说| 欧美一区二区黄色| 国产精品456| 亚洲最快最全在线视频| 欧美一级xxx| 成人激情黄色小说| 午夜精品久久久久久| 久久蜜桃av一区二区天堂| 成人综合激情网| 亚洲国产一区二区三区| 日韩精品中文字幕一区| av动漫一区二区| 青青草国产成人99久久| 又紧又大又爽精品一区二区| 中文天堂在线一区| 久久看人人爽人人| 欧美欧美午夜aⅴ在线观看| 色综合中文字幕国产| 国产精品原创巨作av| 青草国产精品久久久久久| 亚洲第一福利一区| 一区二区三国产精华液| 亚洲欧美一区二区三区久本道91| 欧美videossexotv100| 7777精品伊人久久久大香线蕉经典版下载 | 国产精品影音先锋| 精品一区二区影视| 久久激情五月婷婷| 麻豆精品国产91久久久久久| 日韩电影在线观看一区| 午夜天堂影视香蕉久久| 亚洲国产乱码最新视频 | 免费成人美女在线观看| 国产精品久久久久久户外露出| 日韩欧美国产麻豆| 日韩欧美久久久| 日韩女同互慰一区二区| 欧美一区二区三区四区久久| 欧美蜜桃一区二区三区| 欧美日韩一级视频| 欧美午夜一区二区三区免费大片| 成人av电影在线观看| av电影天堂一区二区在线观看| 岛国一区二区在线观看| 国产一区二区成人久久免费影院| 精品一区二区三区不卡| 国产一区福利在线| 成人国产精品视频| 日本韩国欧美一区二区三区| 欧美日韩亚洲综合一区| 欧美一区二区三区在线| 2021国产精品久久精品| 久久久久久麻豆| 亚洲免费电影在线| 亚洲国产成人porn| 国内久久精品视频| 成人蜜臀av电影| 无码av免费一区二区三区试看 | 国产福利一区二区三区视频在线| 国产在线播精品第三| eeuss鲁片一区二区三区| 91成人免费在线| 日韩一区和二区| 国产精品乱人伦中文| 亚洲一线二线三线久久久| 日本欧美在线观看| www..com久久爱| 欧美精品电影在线播放| 国产喂奶挤奶一区二区三区| 日韩理论片一区二区| 麻豆91免费观看| 丰满放荡岳乱妇91ww| 色哟哟在线观看一区二区三区| 日韩一区二区三区电影在线观看 | 免费成人av在线| 成人久久视频在线观看| 欧美日韩视频专区在线播放|