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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_q.c

?? uCOS開發(fā)與源碼
?? 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();

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚州成人在线电影| 亚洲伊人色欲综合网| 中文幕一区二区三区久久蜜桃| 丁香激情综合五月| 亚洲成人资源网| 中文av一区二区| 日韩欧美的一区| 欧美日韩亚洲另类| a亚洲天堂av| 国产一区二区网址| 日韩中文字幕1| 亚洲美女屁股眼交3| 国产欧美一区二区精品性色超碰| 欧美精品免费视频| 色av一区二区| 99久久精品情趣| 国产一区视频导航| 久久精品国产一区二区| 婷婷一区二区三区| 亚洲一区二区不卡免费| 国产精品美日韩| 欧美国产亚洲另类动漫| 26uuu亚洲综合色欧美| 91精品国产91久久综合桃花| 欧美色成人综合| 日本韩国精品一区二区在线观看| 国产v综合v亚洲欧| 国产一区二区成人久久免费影院 | 久久精品国产精品青草| 亚洲综合色丁香婷婷六月图片| 亚洲欧洲韩国日本视频| 国产精品毛片久久久久久久| 国产日韩欧美在线一区| 欧美大片在线观看一区| 日韩欧美在线影院| 欧美不卡一区二区| 欧美大片拔萝卜| 精品成人免费观看| 精品电影一区二区| 久久亚洲捆绑美女| 国产日韩精品一区二区三区在线| 久久精品欧美日韩精品| 国产视频不卡一区| 国产精品久久久久三级| 1000部国产精品成人观看| 亚洲三级在线播放| 亚洲影视资源网| 日韩中文字幕一区二区三区| 五月天亚洲精品| 麻豆精品在线视频| 国产精品亚洲一区二区三区在线 | av激情综合网| 日本精品一区二区三区高清 | 欧美日韩午夜在线| 欧美乱妇一区二区三区不卡视频| 欧美一区二区三区婷婷月色| 奇米影视7777精品一区二区| 日本美女一区二区三区| 国产在线精品一区在线观看麻豆| 国产美女一区二区三区| 不卡影院免费观看| 在线精品亚洲一区二区不卡| 911精品国产一区二区在线| 日韩美一区二区三区| 国产欧美一区二区精品秋霞影院| 亚洲视频一区在线观看| 石原莉奈在线亚洲二区| 国产精品一区一区三区| 91免费精品国自产拍在线不卡| 欧美日韩电影在线播放| www精品美女久久久tv| 1区2区3区国产精品| 亚洲成人av一区二区| 韩国av一区二区三区| 91麻豆视频网站| 日韩欧美综合在线| 综合久久综合久久| 免费黄网站欧美| 成人福利电影精品一区二区在线观看| 日本道在线观看一区二区| 91精品国产aⅴ一区二区| 中国色在线观看另类| 五月激情综合色| 国产精品亚洲一区二区三区在线| 色综合久久久久久久久| 日韩欧美一区二区不卡| 日韩美女精品在线| 国产真实精品久久二三区| 91福利区一区二区三区| 久久在线观看免费| 亚洲国产精品自拍| 懂色av一区二区三区免费看| 91精品国产综合久久久蜜臀粉嫩| 国产精品久久久一本精品| 精品中文字幕一区二区| 欧美中文字幕一区二区三区亚洲| 久久品道一品道久久精品| 亚洲国产成人91porn| 大尺度一区二区| 精品国产91乱码一区二区三区| 一区二区免费视频| 成人小视频免费在线观看| 欧美一区二区三区四区在线观看 | 亚洲欧美日韩国产一区二区三区 | 亚洲高清免费视频| 成人av影视在线观看| 欧美成人精品1314www| 亚洲国产视频a| 99久久精品免费| 久久久久久97三级| 奇米影视一区二区三区| 欧美日韩一区二区不卡| 亚洲人成网站在线| 波多野结衣精品在线| 国产色爱av资源综合区| 精品国产成人在线影院 | 99在线精品免费| 国产欧美日韩在线| 国产在线精品一区二区不卡了| 欧美人与禽zozo性伦| 亚洲国产一区在线观看| 色婷婷国产精品| 自拍偷拍欧美激情| 成人黄色777网| 中文字幕不卡一区| 国产69精品久久久久毛片| 久久久久久久久久久久久久久99 | 一区二区三区丝袜| 91在线播放网址| 亚洲欧美日韩国产一区二区三区| 91视频www| 最新高清无码专区| 日本乱码高清不卡字幕| 亚洲最大色网站| 欧美性做爰猛烈叫床潮| 亚洲最新视频在线播放| 欧美性色综合网| 日日夜夜精品视频天天综合网| 欧美精品三级日韩久久| 日韩成人午夜电影| 日韩视频免费观看高清完整版在线观看| 亚洲妇女屁股眼交7| 欧美视频一区二区在线观看| 亚洲伊人色欲综合网| 欧美精品日韩一本| 精品一区二区三区香蕉蜜桃| 久久嫩草精品久久久久| 成人在线综合网| 亚洲蜜臀av乱码久久精品| 在线观看免费亚洲| 日韩国产精品大片| 久久综合九色综合97婷婷女人 | 精品少妇一区二区三区免费观看 | jizzjizzjizz欧美| 一区二区在线观看视频| 欧美无砖专区一中文字| 捆绑变态av一区二区三区| 久久久久99精品国产片| 波多野结衣亚洲| 天天色综合成人网| 久久久久免费观看| 91麻豆蜜桃一区二区三区| 亚洲精选在线视频| 欧美一区二区人人喊爽| 福利一区福利二区| 一区二区三区不卡在线观看 | 亚洲福利一区二区三区| 亚洲精品在线电影| gogogo免费视频观看亚洲一| 色综合 综合色| 日本不卡在线视频| 国产免费观看久久| 欧美伊人久久久久久午夜久久久久| 日本三级亚洲精品| 欧美高清在线一区| 欧美日韩www| 国产91在线观看| 日韩国产精品91| 亚洲天堂网中文字| 欧美一区2区视频在线观看| 成人永久看片免费视频天堂| 性久久久久久久久| 国产精品午夜在线| 日韩小视频在线观看专区| jlzzjlzz欧美大全| 亚洲高清视频中文字幕| 久久久久久久久久久黄色| 欧美性高清videossexo| 色婷婷综合在线| 专区另类欧美日韩| 成人一级片网址| 一本大道久久a久久精品综合| 蜜桃视频一区二区| 亚洲精品视频观看| 久久亚洲精品小早川怜子| 欧美高清视频在线高清观看mv色露露十八 | 久久se这里有精品| 亚洲国产精品欧美一二99| 欧美国产欧美亚州国产日韩mv天天看完整| 欧美午夜片在线观看|