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

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

?? os_q.c

?? 非常實用的參考資料
?? 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一区二区三区免费野_久草精品视频
亚洲永久免费视频| 91精品国产综合久久小美女| 欧美激情一区二区三区不卡| 高清在线成人网| 中文字幕一区二| 在线亚洲人成电影网站色www| 中日韩av电影| 91免费版在线| 日韩成人av影视| 久久久久国产一区二区三区四区| 成人免费的视频| 亚洲精品视频在线看| 欧美丰满嫩嫩电影| 国产精品一线二线三线| 国产精品水嫩水嫩| 欧美三级一区二区| 国内久久精品视频| 中文字幕在线观看不卡| 欧美揉bbbbb揉bbbbb| 激情欧美一区二区三区在线观看| 久久久久国产成人精品亚洲午夜| 成人丝袜18视频在线观看| 洋洋成人永久网站入口| 欧美一级黄色录像| 波多野结衣中文一区| 午夜精品久久久久久久久久| 久久青草欧美一区二区三区| 欧美视频在线一区二区三区 | 福利一区福利二区| 亚洲乱码国产乱码精品精98午夜| 91精品国产综合久久福利| 国产成人午夜电影网| 一区二区三区视频在线观看| 精品日韩欧美在线| 在线亚洲一区二区| 色成年激情久久综合| 免费三级欧美电影| 亚洲欧美一区二区三区国产精品| 91精品免费在线观看| 91丨porny丨国产入口| 免费xxxx性欧美18vr| 1024成人网| 久久综合九色综合久久久精品综合| 在线视频国内一区二区| 国产精一区二区三区| 午夜精品福利一区二区蜜股av| 久久久www免费人成精品| 555www色欧美视频| 日本视频中文字幕一区二区三区| 国产精品视频观看| 日韩欧美第一区| 欧美日韩一区二区在线视频| 波多野结衣在线一区| 久久精品国产亚洲a| 午夜精品成人在线| 亚洲激情在线播放| 中文字幕欧美国产| 久久综合精品国产一区二区三区| 欧美亚洲国产一区在线观看网站| bt欧美亚洲午夜电影天堂| 国产精品一区一区| 精品一区二区久久| 蜜桃视频一区二区三区| 亚洲大尺度视频在线观看| 亚洲人一二三区| 中文字幕日韩av资源站| 国产欧美精品一区二区三区四区| 日韩女优av电影| 日韩一区二区精品| 91精品在线免费| 在线播放中文一区| 欧美剧情片在线观看| 欧美日韩在线播放一区| 欧美视频在线一区| 欧美男女性生活在线直播观看| 欧美亚洲自拍偷拍| 欧美日韩精品欧美日韩精品一| 欧美午夜电影一区| 欧美性色欧美a在线播放| 欧美亚洲综合另类| 3751色影院一区二区三区| 欧美精品18+| 欧美岛国在线观看| 久久久精品国产免大香伊| 久久精品人人做人人爽人人| 中文字幕不卡在线| 亚洲日本青草视频在线怡红院| 亚洲欧洲av另类| 伊人开心综合网| 亚洲成av人片| 激情久久五月天| 国产精品88av| 91亚洲精品久久久蜜桃网站| 欧美色倩网站大全免费| 欧美一区二区久久久| 精品成人在线观看| 国产精品久久福利| 一区二区高清在线| 热久久久久久久| 国产ts人妖一区二区| 91国在线观看| 欧美一二三区在线| 国产精品区一区二区三| 亚洲精品日韩综合观看成人91| 性久久久久久久久久久久| 蜜桃视频在线观看一区| 成人中文字幕合集| 日韩一区二区在线观看视频| 久久毛片高清国产| 亚洲一区在线观看免费观看电影高清| 日韩国产欧美三级| 成人精品一区二区三区中文字幕| 欧美四级电影网| 国产欧美日韩麻豆91| 亚洲国产va精品久久久不卡综合| 精品一区二区三区影院在线午夜| 波多野结衣一区二区三区| 欧美日韩亚洲不卡| 国产视频一区不卡| 亚洲成人一二三| 国产69精品久久777的优势| 欧美日本在线观看| 国产精品欧美一区喷水| 丝袜美腿亚洲综合| 成人涩涩免费视频| 91精品国产欧美日韩| 国产精品青草综合久久久久99| 日韩1区2区日韩1区2区| 91老司机福利 在线| 精品对白一区国产伦| 亚洲国产综合人成综合网站| 国产不卡免费视频| 欧美精品亚洲二区| 国产精品国产三级国产专播品爱网| 美女在线视频一区| 欧美视频你懂的| 国产精品电影一区二区三区| 国产在线国偷精品免费看| 欧美三级电影在线看| 国产精品第四页| 国产成人久久精品77777最新版本| 欧美日韩精品一区视频| 中文字幕一区免费在线观看| 国产原创一区二区三区| 欧美丰满一区二区免费视频| 一区2区3区在线看| 成人av免费在线播放| 久久中文字幕电影| 免费人成精品欧美精品| 欧美在线观看禁18| 成人欧美一区二区三区小说| 国产91精品入口| 久久亚洲一区二区三区明星换脸 | 欧美国产精品中文字幕| 狠狠色狠狠色综合系列| 欧美一区三区四区| 亚洲国产一区二区三区青草影视 | 欧美撒尿777hd撒尿| 亚洲精品国产精品乱码不99| 99久久99久久精品国产片果冻 | bt欧美亚洲午夜电影天堂| 国产婷婷色一区二区三区四区 | 午夜精品福利一区二区三区蜜桃| 91在线观看成人| 亚洲人成网站精品片在线观看 | 久久成人久久爱| 欧美成人精精品一区二区频| 青青草97国产精品免费观看 | 极品美女销魂一区二区三区| 欧美日韩免费高清一区色橹橹| 亚洲卡通动漫在线| 欧美中文字幕一区| 日韩和欧美一区二区| 欧美一级二级三级乱码| 久久精品国产色蜜蜜麻豆| 日韩美女天天操| 精品在线亚洲视频| 久久久综合激的五月天| 国产xxx精品视频大全| 国产精品进线69影院| 欧美日韩视频专区在线播放| 日本一道高清亚洲日美韩| 这里只有精品电影| 国产在线国偷精品免费看| 国产女人aaa级久久久级| 99久久精品国产观看| 亚洲一区二区视频在线观看| 91精品国产综合久久久久久久久久| 日韩电影免费在线| 久久久久国产精品免费免费搜索| 成人爱爱电影网址| 一区二区三区精密机械公司| 欧美日韩一区二区电影| 美女高潮久久久| 国产精品激情偷乱一区二区∴| 在线看日本不卡| 久久成人免费电影| 国产精品久久777777| 欧美美女直播网站| 国产精品原创巨作av|