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

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

?? os_q.c

?? uc0s zai 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 "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();

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一区二区三区国色天香| 国产精品乡下勾搭老头1| 91视频观看视频| 亚洲va欧美va人人爽| 91丨九色丨黑人外教| 亚洲视频免费看| 在线区一区二视频| 亚洲国产成人va在线观看天堂| 日本黄色一区二区| 日韩高清一区在线| 国产欧美一区二区在线观看| 99久久99久久久精品齐齐| 亚洲男帅同性gay1069| 在线观看网站黄不卡| 亚洲二区视频在线| 久久久久久久久岛国免费| 成人久久久精品乱码一区二区三区| 亚洲国产精品成人综合色在线婷婷| 91亚洲男人天堂| 久久国产精品99精品国产 | 免费在线观看精品| 中文字幕日本乱码精品影院| 欧美一区日韩一区| 成人sese在线| 国产精品一区二区男女羞羞无遮挡 | 亚洲欧美日韩在线不卡| 日韩亚洲欧美综合| 91美女在线视频| 成人黄色软件下载| 久久99精品国产91久久来源| 亚洲一区在线观看免费| 精品久久一二三区| 久久精品国产亚洲5555| 精品国产91洋老外米糕| 51精品国自产在线| 色屁屁一区二区| 成人动漫在线一区| 欧美四级电影在线观看| 国产精品一区二区久久不卡| 日韩福利电影在线观看| 一区二区三区在线视频观看| 国产欧美一区在线| 欧美精彩视频一区二区三区| 欧美成人福利视频| 久久嫩草精品久久久精品| 欧美不卡激情三级在线观看| 欧美一区二区三区喷汁尤物| 欧美日韩国产综合草草| 欧美军同video69gay| 欧美人伦禁忌dvd放荡欲情| 欧美日韩中文字幕一区| 欧美伦理电影网| 欧美不卡在线视频| 国产精品天干天干在线综合| 国产精品麻豆一区二区| 亚洲美女屁股眼交| 午夜精品久久久久影视| 裸体歌舞表演一区二区| 国产成人a级片| 在线日韩av片| 精品sm捆绑视频| 樱桃视频在线观看一区| 美国av一区二区| 成人av资源在线观看| 欧美日韩久久久久久| 精品福利一区二区三区| 亚洲欧美国产77777| 久久国产婷婷国产香蕉| 日本高清视频一区二区| 欧美老年两性高潮| 久久九九99视频| 亚洲一区二区在线免费观看视频| 毛片av一区二区| 在线视频你懂得一区二区三区| 久久亚洲欧美国产精品乐播| 亚洲综合无码一区二区| 国产黄色成人av| 日韩无一区二区| 国产91在线观看| 666欧美在线视频| 一区二区三区在线播| 99久久精品免费精品国产| 日韩精品自拍偷拍| 日韩高清在线观看| 欧美色成人综合| 亚洲一区在线播放| 一本色道**综合亚洲精品蜜桃冫| 久久精品人人做人人爽人人| 久久爱另类一区二区小说| 欧美日韩在线播放一区| 亚洲欧美国产三级| 91成人网在线| 亚洲成人免费av| 7777精品久久久大香线蕉| 亚洲国产欧美一区二区三区丁香婷| 99re在线视频这里只有精品| 《视频一区视频二区| jlzzjlzz国产精品久久| 亚洲女同女同女同女同女同69| eeuss鲁片一区二区三区在线观看| 欧美国产激情二区三区| 99久久伊人久久99| 亚洲精选视频免费看| 91久久香蕉国产日韩欧美9色| 亚洲精品日产精品乱码不卡| 欧美日韩成人综合天天影院| 亚洲成a人片在线观看中文| 日韩片之四级片| 成人午夜电影小说| 一区二区三区视频在线看| 91精品国产91综合久久蜜臀| 激情综合一区二区三区| 国产精品免费丝袜| 欧美日韩一区二区欧美激情| 韩国一区二区在线观看| 国产精品国产三级国产专播品爱网| 91久久精品一区二区二区| 免费在线成人网| 亚洲色图都市小说| 久久久久国产精品麻豆ai换脸| 一本大道综合伊人精品热热| 男人的j进女人的j一区| 国产一区二区三区观看| 亚洲激情第一区| 久久免费国产精品| 欧美精品tushy高清| 成人免费黄色在线| 国产伦理精品不卡| 麻豆精品新av中文字幕| 亚洲九九爱视频| 国产精品电影院| 中国av一区二区三区| 欧美成人一区二区三区| 欧美精品一二三四| 色婷婷av一区二区三区软件| 国产美女视频91| 久久精品免费观看| 日韩福利视频导航| 日本一区中文字幕| 日本不卡123| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲国产欧美一区二区三区丁香婷| 中文字幕在线免费不卡| 亚洲少妇30p| 夜色激情一区二区| 天使萌一区二区三区免费观看| 一区二区三区国产精华| 亚洲一区二区三区小说| 婷婷综合久久一区二区三区| 亚洲一区二区av电影| 天天亚洲美女在线视频| 麻豆成人在线观看| 国产盗摄一区二区三区| 99re视频精品| 欧美高清视频不卡网| 久久免费视频色| 亚洲人成在线播放网站岛国| 一区二区不卡在线播放| 免费观看一级欧美片| 成人免费黄色在线| 欧美日本国产视频| 久久久美女艺术照精彩视频福利播放| 国产女主播一区| 日韩一区精品字幕| av在线综合网| 欧美一卡在线观看| 亚洲色图在线播放| 国产做a爰片久久毛片| 91免费视频网| 久久精品免视看| 午夜精品一区二区三区电影天堂 | 又紧又大又爽精品一区二区| 美女看a上一区| 欧美性色欧美a在线播放| 精品美女在线观看| 日本午夜精品视频在线观看| 91视频你懂的| 一区精品在线播放| 国产一区二区三区久久悠悠色av| 色狠狠桃花综合| 中文字幕一区二区在线播放| 美女任你摸久久| 91精品国产综合久久久蜜臀粉嫩| 亚洲色图20p| 国产成人日日夜夜| 久久久99久久| 久草在线在线精品观看| 欧美一区二区啪啪| 免费精品99久久国产综合精品| 色94色欧美sute亚洲线路一久| 中文字幕色av一区二区三区| 国产精品一线二线三线精华| 欧美v亚洲v综合ⅴ国产v| 麻豆91小视频| 久久亚洲影视婷婷| 国产精品1区2区3区| 国产精品久久久久久久久久免费看 | 国产精品乱码一区二区三区软件| 床上的激情91.| 亚洲伊人色欲综合网|