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

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

?? os_q.c

?? LPC2104/5/6嵌入式系統程序實例,帶有PROTUES7.1仿真文件,適合做入門指導
?? 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影院在线免费观看| 欧美videofree性高清杂交| 青青草国产成人av片免费| 日韩欧美一二区| 粉嫩aⅴ一区二区三区四区五区| 欧美韩日一区二区三区| 色婷婷激情综合| 五月天婷婷综合| 日韩免费观看2025年上映的电影| 精品一区二区av| 亚洲欧洲日韩综合一区二区| 欧美综合久久久| 麻豆freexxxx性91精品| 亚洲国产精品二十页| 色综合久久综合网97色综合| 亚洲一区二区在线观看视频| 欧美一级日韩免费不卡| 国产麻豆精品久久一二三| 亚洲美女视频在线| 日本一区二区免费在线观看视频 | 欧美一级黄色录像| 国产一区二区三区视频在线播放| 国产精品高潮呻吟| 欧美精品日韩综合在线| 国产精品综合二区| 亚洲综合小说图片| 精品福利一二区| 91老师片黄在线观看| 日本中文在线一区| 中文字幕综合网| 日韩欧美一区电影| 日本乱人伦一区| 狠狠色伊人亚洲综合成人| 一区二区三区中文在线观看| 精品国产乱码久久久久久老虎 | 91黄色免费看| 久久99精品一区二区三区| 亚洲激情自拍视频| 久久久噜噜噜久久中文字幕色伊伊 | 成人免费毛片嘿嘿连载视频| 亚洲国产日产av| 国产日韩欧美精品在线| 欧美日韩视频第一区| 99在线精品免费| 国内久久精品视频| 婷婷久久综合九色综合伊人色| 国产欧美精品国产国产专区| 日韩欧美黄色影院| 欧美三级电影一区| 91亚洲精品一区二区乱码| 韩国精品一区二区| 日韩av一级电影| 亚洲午夜精品在线| 亚洲三级电影全部在线观看高清| 国产午夜精品福利| 欧美成人一区二区| 91精品蜜臀在线一区尤物| 色综合一个色综合亚洲| 国产不卡视频在线观看| 精品午夜久久福利影院| 天堂一区二区在线| 亚洲国产一区二区三区青草影视| 中文字幕在线一区| 国产精品三级av| 欧美国产精品v| 久久精品一区二区三区四区| 精品国产一区二区三区久久久蜜月| 欧美精品亚洲二区| 欧美欧美欧美欧美首页| 欧美三片在线视频观看| 在线区一区二视频| 色诱视频网站一区| 91福利国产成人精品照片| 91在线无精精品入口| 99久久99久久精品免费看蜜桃| 国产suv精品一区二区三区| 国产一区二区在线视频| 国产成人亚洲精品青草天美| 国产经典欧美精品| 不卡视频免费播放| 97国产一区二区| 欧美亚洲高清一区| 精品视频资源站| 日韩欧美一区二区不卡| 国产亚洲制服色| 中文字幕一区二区三区乱码在线| 综合av第一页| 五月综合激情婷婷六月色窝| 日韩高清在线一区| 国产精品一区二区在线观看网站| 国产成人丝袜美腿| 91麻豆精品视频| 欧美日韩国产综合视频在线观看| 欧美高清视频一二三区| 久久欧美一区二区| 亚洲欧洲精品天堂一级 | 国产日韩欧美在线一区| 国产免费观看久久| 国产日本欧美一区二区| 久久久久久久久久看片| 国产日韩欧美综合在线| 国产精品传媒入口麻豆| 最新不卡av在线| 国产三级精品三级| 亚洲国产精品麻豆| 婷婷开心激情综合| 精品一区二区三区免费| 国产精品羞羞答答xxdd| 成人免费看视频| 欧美日韩性生活| 精品国产青草久久久久福利| 国产午夜精品美女毛片视频| 国产精品久久看| 亚洲免费观看高清| 亚洲丝袜自拍清纯另类| 玖玖九九国产精品| 国产精品一区二区久激情瑜伽 | 99r国产精品| 欧美日韩国产高清一区二区 | 欧美aⅴ一区二区三区视频| 久久国产精品一区二区| 不卡影院免费观看| 777精品伊人久久久久大香线蕉| 国产欧美精品在线观看| 亚洲国产精品综合小说图片区| 日本aⅴ免费视频一区二区三区 | 国产成人亚洲综合a∨婷婷图片| 99精品视频在线播放观看| 欧美精品一区二区三区蜜桃| 国产精品久久久久一区 | 国产欧美日本一区视频| 亚洲成人av电影在线| 国产成人午夜高潮毛片| 欧美亚洲愉拍一区二区| 日韩午夜精品视频| 亚洲精品高清在线观看| 国内精品第一页| 丰满亚洲少妇av| 欧美色男人天堂| 精品第一国产综合精品aⅴ| 亚洲综合成人在线| 国产一区二区精品久久91| 日本韩国欧美三级| 欧美成人高清电影在线| 亚洲国产aⅴ成人精品无吗| 国产成人av福利| 日韩欧美综合一区| 一区二区高清免费观看影视大全| 五月天一区二区三区| 欧美视频在线一区二区三区 | 在线亚洲一区二区| 久久人人爽爽爽人久久久| 亚洲国产一区二区三区| www.欧美亚洲| 久久综合av免费| 蜜臀av亚洲一区中文字幕| 一本大道av伊人久久综合| 久久久99精品免费观看不卡| 欧美aaaaaa午夜精品| 欧美三级韩国三级日本三斤| 亚洲成人午夜影院| 91麻豆国产福利在线观看| 国产欧美日韩亚州综合| 久久69国产一区二区蜜臀| 欧美日韩亚洲综合一区二区三区| 亚洲国产成人va在线观看天堂| 97成人超碰视| 中文字幕亚洲一区二区va在线| 国产一区二区三区综合| 91精品国产入口| 看电影不卡的网站| 欧美一区二区精品| 夜夜嗨av一区二区三区中文字幕| jlzzjlzz欧美大全| 国产欧美精品日韩区二区麻豆天美 | 日韩免费高清av| 日韩一区精品字幕| 欧美年轻男男videosbes| 亚洲一区二区免费视频| 欧美在线观看18| 亚洲一二三专区| 91在线免费看| 午夜国产不卡在线观看视频| 欧美日韩一级片在线观看| 无码av免费一区二区三区试看| 欧美日韩精品欧美日韩精品一| 男女性色大片免费观看一区二区 | 中文字幕中文字幕在线一区 | 中国av一区二区三区| 不卡的电影网站| 综合久久国产九一剧情麻豆| 一道本成人在线| 亚洲国产aⅴ天堂久久| 欧美日韩aaaaa| 蜜桃传媒麻豆第一区在线观看| 精品少妇一区二区三区免费观看 | 怡红院av一区二区三区| 欧美撒尿777hd撒尿| 石原莉奈一区二区三区在线观看 |