亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
在线观看av一区二区| 国产综合色在线| 奇米精品一区二区三区在线观看| 亚洲午夜久久久久| 日韩国产欧美在线观看| 韩国成人在线视频| 91女人视频在线观看| 欧美日韩日本视频| 精品对白一区国产伦| 中文字幕日韩精品一区| 亚洲最大成人综合| 理论片日本一区| 成人高清免费在线播放| 欧美日韩高清影院| 久久久久久久久99精品| 亚洲欧洲中文日韩久久av乱码| 日韩av中文在线观看| 国产精品123区| 在线亚洲+欧美+日本专区| 正在播放一区二区| 国产欧美精品区一区二区三区| 一区二区三区美女视频| 久久精品国产999大香线蕉| a4yy欧美一区二区三区| 91精品国产品国语在线不卡| 国产欧美精品日韩区二区麻豆天美 | 欧美日韩一区二区不卡| 久久综合色一综合色88| 夜夜嗨av一区二区三区网页 | 欧美二区乱c少妇| 中文字幕欧美激情一区| 日韩电影在线免费观看| 粉嫩嫩av羞羞动漫久久久| 成人精品视频.| 日韩午夜激情电影| 亚洲免费观看高清完整| 激情深爱一区二区| 欧美日韩一卡二卡三卡| 久久影视一区二区| 亚洲一区日韩精品中文字幕| 高清在线观看日韩| 日韩欧美国产综合一区| 一个色在线综合| 成人综合婷婷国产精品久久| 欧美一区二区三区精品| 一区二区三区高清在线| 成人黄色在线视频| 久久久亚洲精华液精华液精华液| 亚洲成av人**亚洲成av**| 不卡电影免费在线播放一区| 精品国产乱码久久久久久蜜臀| 亚洲综合激情网| youjizz国产精品| 久久蜜臀精品av| 美国欧美日韩国产在线播放| 欧美色成人综合| 亚洲男人电影天堂| 国产成人aaa| www久久精品| 老司机精品视频线观看86 | 日韩影院在线观看| 欧美在线看片a免费观看| 国产精品电影院| 国产成人在线视频播放| 精品国产1区2区3区| 美国欧美日韩国产在线播放| 这里是久久伊人| 日韩二区在线观看| 欧美军同video69gay| 亚洲成人在线观看视频| 91极品视觉盛宴| 亚洲免费视频中文字幕| 91在线观看高清| 中文字幕国产一区| 成人免费毛片app| 国产精品视频看| 成人av电影在线| 国产精品久久久久影院色老大| 国产999精品久久久久久| 久久中文字幕电影| 国产美女av一区二区三区| 亚洲精品一区二区精华| 伦理电影国产精品| 26uuu精品一区二区在线观看| 国产在线精品一区二区| 2023国产一二三区日本精品2022| 国产最新精品免费| 国产欧美一区二区在线观看| 丁香一区二区三区| 17c精品麻豆一区二区免费| 成人精品鲁一区一区二区| 国产精品家庭影院| 色av成人天堂桃色av| 午夜精品久久久久久久久久久| 3d成人动漫网站| 精品一区二区国语对白| 国产亚洲欧美中文| 成人亚洲精品久久久久软件| 最新成人av在线| 欧美性感一区二区三区| 亚洲电影在线播放| 7777精品伊人久久久大香线蕉超级流畅 | 久久久久99精品一区| 国内国产精品久久| 国产精品女主播在线观看| voyeur盗摄精品| 亚洲男人的天堂在线观看| 在线综合视频播放| 久久精品免费看| 久久久久久免费| www.亚洲国产| 亚洲另类一区二区| 国产精品99精品久久免费| 一区免费观看视频| 在线视频你懂得一区二区三区| 亚洲高清不卡在线| 日韩欧美国产综合| 成人激情综合网站| 一区二区三区高清在线| 在线播放/欧美激情| 精品中文字幕一区二区小辣椒| 久久一留热品黄| 99精品久久只有精品| 国产日产欧美一区二区视频| 在线精品亚洲一区二区不卡| 日韩专区一卡二卡| 精品国产乱码久久久久久老虎| 成人免费看片app下载| 午夜精品久久久久久久久久| 国产视频一区在线观看| 福利一区在线观看| 偷拍一区二区三区四区| 精品成人在线观看| 色av成人天堂桃色av| 精品一区中文字幕| 一区二区三区小说| 日韩美女在线视频| 成人激情视频网站| 天天影视涩香欲综合网| 国产人妖乱国产精品人妖| 欧美日韩高清一区二区三区| 国产精品99久| 亚洲视频精选在线| 欧美精品亚洲一区二区在线播放| 美国毛片一区二区三区| **网站欧美大片在线观看| 欧美日韩国产不卡| 成人网页在线观看| 午夜精品久久久| 亚洲日本在线看| 日韩欧美专区在线| 色综合久久88色综合天天免费| 石原莉奈在线亚洲二区| 国产精品乱人伦中文| 在线播放91灌醉迷j高跟美女 | 国内久久精品视频| 亚洲欧美另类综合偷拍| 777xxx欧美| 欧美色图片你懂的| 激情综合色播激情啊| 亚洲第一综合色| 亚洲欧洲另类国产综合| 国产日本亚洲高清| 日韩欧美黄色影院| 欧美在线观看禁18| 成人高清视频在线| 婷婷综合另类小说色区| 亚洲国产婷婷综合在线精品| 国产欧美视频在线观看| 日韩一区二区精品在线观看| 色94色欧美sute亚洲13| 久久机这里只有精品| 天天综合日日夜夜精品| 这里是久久伊人| 在线视频一区二区免费| 99久久国产综合精品色伊| 蜜桃视频在线观看一区| 亚洲午夜在线视频| 亚洲色图一区二区| 国产精品视频九色porn| 久久婷婷一区二区三区| 欧美精品乱码久久久久久| 欧美美女黄视频| 色婷婷精品久久二区二区蜜臀av| 国产成人av网站| 激情国产一区二区 | 日本道在线观看一区二区| 国产91精品久久久久久久网曝门| 亚洲成va人在线观看| 亚洲欧美一区二区三区久本道91| 国产欧美日韩久久| 亚洲精品在线观| 日韩一级二级三级| 欧美性高清videossexo| 在线观看欧美黄色| 色婷婷综合中文久久一本| 欧美精品一区二区三区四区| 欧美日韩高清一区二区| 在线观看免费亚洲| 欧美性色黄大片|