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

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

?? os_q.c

?? 這是我買uCOS-II第二版本書帶的光盤的資料
?? 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();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产综合久久蜜臀| 中文字幕一区在线观看| 国产精品久久久久影院老司| 一区二区三区精品| 国产91精品久久久久久久网曝门| 欧美在线一区二区| 国产精品久久久久影院色老大| 日本不卡的三区四区五区| 91在线看国产| 国产女同互慰高潮91漫画| 麻豆一区二区三| 欧美在线色视频| 亚洲男人的天堂在线aⅴ视频| 久久精品噜噜噜成人av农村| 欧美日韩国产高清一区二区三区| 中文字幕一区日韩精品欧美| 国产在线播放一区二区三区| 337p亚洲精品色噜噜狠狠| 亚洲欧美一区二区久久| 成人免费观看av| 国产欧美精品一区aⅴ影院| 久久成人久久爱| 精品国产乱码久久久久久影片| 日韩高清国产一区在线| 欧美亚洲一区三区| 亚洲精品美国一| 成人av网站在线| **网站欧美大片在线观看| 97se亚洲国产综合在线| 亚洲欧美韩国综合色| 色噜噜偷拍精品综合在线| 亚洲欧美另类综合偷拍| 成人av网站在线| 亚洲欧美色一区| 在线精品视频一区二区三四 | 亚洲欧美日韩国产另类专区| 成人动漫视频在线| 亚洲三级电影全部在线观看高清| 波多野结衣中文字幕一区二区三区 | 日本美女一区二区| 日韩欧美激情一区| 激情成人综合网| 国产女人aaa级久久久级| av中文字幕不卡| 亚洲综合久久久久| 日韩亚洲欧美综合| 国产精品亚洲第一| 国产精品不卡在线| 91美女在线视频| 日韩精品一区第一页| 欧美成人乱码一区二区三区| 精品一区二区综合| 国产精品成人在线观看| 欧美日韩高清一区二区三区| 久久成人精品无人区| 中文字幕成人网| 91搞黄在线观看| 久久精品国产久精国产| 国产精品嫩草久久久久| 欧美亚日韩国产aⅴ精品中极品| 麻豆91在线播放| 国产精品国产三级国产普通话蜜臀| 91浏览器在线视频| 久久99这里只有精品| 亚洲欧美激情一区二区| 精品国产99国产精品| 94色蜜桃网一区二区三区| 日韩电影在线一区| 最好看的中文字幕久久| 精品美女被调教视频大全网站| 99精品一区二区| 国产一区二区三区综合| 亚洲国产视频直播| 中文字幕久久午夜不卡| 7777精品伊人久久久大香线蕉超级流畅 | 午夜久久久影院| 欧美一区2区视频在线观看| 国产高清无密码一区二区三区| 亚洲一区在线看| 国产网红主播福利一区二区| 在线一区二区视频| 国产精品 日产精品 欧美精品| 亚洲午夜激情网页| 国产精品福利av| 久久色.com| 在线成人av网站| 色丁香久综合在线久综合在线观看| 精品一区二区三区在线播放| 亚洲最大成人网4388xx| 国产精品嫩草99a| 久久这里只有精品视频网| 欧美天堂亚洲电影院在线播放| 成人禁用看黄a在线| 狠狠色丁香婷综合久久| 日本欧美肥老太交大片| 亚洲一区电影777| 亚洲免费观看视频| 中文字幕在线不卡国产视频| 久久久青草青青国产亚洲免观| 欧美一级xxx| 欧美人妖巨大在线| 色婷婷综合久久| 色综合天天综合色综合av| 国产精品综合久久| 韩国一区二区三区| 国产一区二三区| 国内外成人在线视频| 日本午夜精品视频在线观看 | 日本一区二区三区国色天香 | 欧美肥妇free| 欧美久久久久免费| 欧美狂野另类xxxxoooo| 欧美日韩精品久久久| 欧美色网一区二区| 日韩一区二区精品在线观看| 91精品免费观看| 日韩一区二区三区在线视频| 日韩一级免费观看| 国产亚洲1区2区3区| 国产欧美精品区一区二区三区| 国产欧美日韩综合精品一区二区| 国产女主播视频一区二区| 国产精品护士白丝一区av| 亚洲欧美色综合| 亚洲成人在线网站| 美国av一区二区| 国产一区二区三区免费观看| 国产成人精品一区二区三区四区 | 日本vs亚洲vs韩国一区三区二区| 污片在线观看一区二区| 久色婷婷小香蕉久久| 国产成人综合自拍| 一本到不卡免费一区二区| 欧美在线你懂得| 日韩精品一区二区三区蜜臀| 国产日韩欧美综合在线| 国产精品久久久久久久久免费桃花| 亚洲另类春色校园小说| 午夜精品福利久久久| 国产一区二区剧情av在线| 成人a级免费电影| 欧美日韩dvd在线观看| 欧美xxx久久| 依依成人精品视频| 久久成人免费日本黄色| www.日韩在线| 制服丝袜中文字幕一区| 日本一区二区视频在线观看| 亚洲成人三级小说| 丁香激情综合国产| 欧美一区二区在线不卡| 国产精品久久久久一区二区三区 | 欧美性受xxxx黑人xyx| xfplay精品久久| 亚洲欧美日韩综合aⅴ视频| 美国av一区二区| 91福利国产精品| 久久这里都是精品| 午夜视频久久久久久| 成人精品一区二区三区中文字幕| 欧美人体做爰大胆视频| 国产精品乱码一区二区三区软件 | 国产日韩欧美亚洲| 五月天激情综合网| 91在线观看免费视频| 久久久亚洲高清| 美女在线一区二区| 欧美视频完全免费看| 中文字幕日韩av资源站| 国产一区二区三区在线观看免费视频 | 亚洲视频在线一区二区| 国内精品第一页| 制服丝袜一区二区三区| 洋洋成人永久网站入口| 99国产精品99久久久久久| 欧美精品一区二区不卡| 蜜桃av一区二区在线观看| 欧美日韩在线播| 亚洲黄色录像片| 99国产精品久久久久久久久久久 | 亚洲成人一区二区| 91片黄在线观看| 综合久久给合久久狠狠狠97色| 国模套图日韩精品一区二区| 7777精品伊人久久久大香线蕉最新版| 国产精品久久久久久久久免费樱桃| 国产一区二区0| 精品国产制服丝袜高跟| 毛片av一区二区三区| 91麻豆精品国产91久久久 | 日本亚洲最大的色成网站www| 日本高清不卡一区| 亚洲欧美日韩系列| 99久久久国产精品| 亚洲女同一区二区| 欧美日韩亚洲国产综合| 亚洲高清免费视频| 欧美一区三区二区| 国产在线一区二区综合免费视频| 久久综合久久综合久久|