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

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

?? os_q.c

?? 562uCOS-II_2.52在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)
{

    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)
{

    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)
{

    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一区二区三区免费野_久草精品视频
91福利国产成人精品照片| 色综合天天综合| 91福利在线免费观看| 日本在线播放一区二区三区| 欧美性xxxxx极品少妇| 亚洲欧美日韩在线| 97久久人人超碰| 中文字幕欧美一| 成人av网站免费| **网站欧美大片在线观看| 69久久99精品久久久久婷婷| 亚洲丰满少妇videoshd| 欧美性猛交xxxxxx富婆| 粉嫩aⅴ一区二区三区四区五区| 精品国产a毛片| 国产露脸91国语对白| 久久久噜噜噜久久人人看| 国产福利91精品一区二区三区| 国产精品天干天干在线综合| 成熟亚洲日本毛茸茸凸凹| 一区二区三区在线视频播放| 欧美亚洲国产一区在线观看网站 | 久久精品国产99久久6| 51午夜精品国产| 99re这里只有精品6| 国产乱码精品一区二区三区五月婷| 午夜久久久影院| 久久午夜电影网| zzijzzij亚洲日本少妇熟睡| 亚洲国产美女搞黄色| 中文字幕一区二区三区精华液| 欧美xxxxxxxx| 91香蕉视频污在线| 日本欧美在线看| 亚洲成人免费看| 欧美mv日韩mv国产| 欧美二区三区91| 成人蜜臀av电影| 国产91综合一区在线观看| 久久99精品国产麻豆婷婷| 中文字幕第一页久久| 69精品人人人人| 欧美日本一道本在线视频| 国产福利一区二区三区视频| 国产在线精品一区二区不卡了| 亚洲欧洲中文日韩久久av乱码| 亚洲国产精品传媒在线观看| 久久久久久久综合日本| 欧美精品一区二区三区在线播放| 日韩三级电影网址| 在线观看日韩一区| 国产精品系列在线观看| 国产福利一区在线观看| 国产成人在线视频网站| 国产.欧美.日韩| 成人av电影免费在线播放| 成人午夜电影久久影院| 成人app网站| 欧美性受xxxx黑人xyx| 欧美美女视频在线观看| 在线播放中文字幕一区| 日韩午夜精品电影| 久久亚洲综合av| 欧美激情综合五月色丁香小说| 中文字幕欧美国产| 亚洲男人电影天堂| 亚洲高清一区二区三区| 美美哒免费高清在线观看视频一区二区| 国产欧美一区二区精品秋霞影院| 欧美日韩国产大片| 日韩精品一区二区在线| 欧美三级欧美一级| 色妹子一区二区| 丁香网亚洲国际| 一本大道久久a久久综合| 欧美体内she精视频| 日韩一区二区麻豆国产| 精品欧美一区二区久久 | 综合色中文字幕| 久久香蕉国产线看观看99| 亚洲国产精品激情在线观看| 亚洲精品视频一区二区| 国产精品三级电影| 亚洲一区二区三区视频在线播放 | 国产精品99久| 色伊人久久综合中文字幕| 91.com在线观看| 久久精品在线免费观看| 精品乱码亚洲一区二区不卡| 国产精品午夜在线| 日欧美一区二区| 午夜久久电影网| 国产一区二区福利视频| 色88888久久久久久影院野外| 欧美日韩激情一区二区| 久久色.com| 亚洲国产精品久久人人爱蜜臀| 韩日欧美一区二区三区| 国产福利一区二区三区| 欧美日韩一级视频| 国产精品久久久久9999吃药| 国产精品国产三级国产普通话蜜臀 | 成人欧美一区二区三区小说| 日韩av一区二区在线影视| 成人国产精品免费网站| 欧美一区二区在线观看| 4438x成人网最大色成网站| 国产日韩欧美精品综合| 日韩av中文字幕一区二区| zzijzzij亚洲日本少妇熟睡| 91精品国产欧美一区二区18 | 国产不卡视频在线观看| 欧美一区二区观看视频| 亚洲免费观看高清完整版在线| 国产综合色产在线精品| 欧美日韩午夜精品| 亚洲欧美另类久久久精品2019| 国产一区三区三区| 欧美日韩黄色影视| 亚洲欧洲日产国产综合网| 韩国午夜理伦三级不卡影院| 欧美精品久久久久久久久老牛影院| 国产精品第五页| 国产高清精品网站| 久久网这里都是精品| 日韩精彩视频在线观看| 91国产丝袜在线播放| 国产精品高潮呻吟久久| 国产福利一区在线| 久久综合色天天久久综合图片| 青青草一区二区三区| 国产成人日日夜夜| 精品国产乱码久久久久久1区2区| 午夜日韩在线观看| 欧美日韩在线播放三区四区| 亚洲三级在线看| 99精品久久免费看蜜臀剧情介绍| 国产日韩精品一区二区三区 | 成人爽a毛片一区二区免费| 欧美成人激情免费网| 青青草伊人久久| 日韩区在线观看| 蜜桃视频一区二区三区在线观看| 欧美tk—视频vk| 久久99久国产精品黄毛片色诱| 欧美一区二区三区系列电影| 日韩制服丝袜先锋影音| 欧美夫妻性生活| 丝袜美腿亚洲一区| 欧美福利视频一区| 奇米一区二区三区av| 日韩一级片网站| 国内精品嫩模私拍在线| 久久久五月婷婷| 成人午夜激情影院| 亚洲欧洲精品成人久久奇米网| 99久久久久久| 亚洲影视资源网| 欧美电影一区二区| 久久国产精品99久久人人澡| 亚洲精品一区二区在线观看| 国产精品一卡二卡| 国产精品美女久久久久aⅴ | 2021国产精品久久精品| 国产精品一区二区在线看| 国产日韩高清在线| 91麻豆精品秘密| 亚洲成人动漫在线免费观看| 91精品国产综合久久精品性色| 蜜桃av一区二区在线观看| 久久综合狠狠综合久久综合88| 国产91富婆露脸刺激对白| 亚洲美女一区二区三区| 色婷婷综合久久久中文字幕| 日韩精品亚洲专区| 久久久久久久电影| 91丨porny丨首页| 五月天一区二区| 国产亚洲精品资源在线26u| 99久久国产综合色|国产精品| 亚洲精品精品亚洲| 日韩三区在线观看| 成人美女在线观看| 手机精品视频在线观看| 国产欧美日韩综合精品一区二区| 色94色欧美sute亚洲线路一久| 日韩不卡一二三区| 国产精品乱人伦一区二区| 精品视频色一区| 国产乱妇无码大片在线观看| 亚洲精品视频免费看| 日韩欧美一区二区免费| 波多野结衣视频一区| 天使萌一区二区三区免费观看| 久久久777精品电影网影网 | 国产色产综合产在线视频| 欧美在线播放高清精品| 国产精品亚洲成人| 亚洲一区二区av在线| 久久精品人人做人人爽人人|