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

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

?? os_q.c

?? 一個最簡單的多任務uCOS2編程事例.運行于LPC2100系列的實驗板
?? 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精品一区二区麻豆网站| 大白屁股一区二区视频| av不卡免费在线观看| 91理论电影在线观看| 欧美私人免费视频| 日韩午夜在线观看视频| 久久久噜噜噜久久中文字幕色伊伊 | 91麻豆精品在线观看| 一区二区三区中文免费| 性久久久久久久久久久久| 青青草精品视频| 国模少妇一区二区三区| 91视频免费播放| 8v天堂国产在线一区二区| 欧美精品一区在线观看| 国产精品国产三级国产| 亚洲不卡一区二区三区| 久草中文综合在线| 色综合久久66| 26uuu精品一区二区三区四区在线| 日本一区二区成人| 偷拍亚洲欧洲综合| 处破女av一区二区| 欧美一区二区三区四区视频| 国产视频一区二区在线| 香蕉久久夜色精品国产使用方法| 国产精品一区二区三区四区 | 亚洲成在线观看| 狠狠色综合日日| 欧美在线啊v一区| 久久精品人人做人人爽人人| 一区二区三区免费看视频| 国产一区二区三区电影在线观看 | 亚洲国产精品自拍| 国产精品亚洲人在线观看| 欧美揉bbbbb揉bbbbb| 国产精品你懂的在线| 青青草97国产精品免费观看无弹窗版| 不卡高清视频专区| 久久综合视频网| 日韩二区在线观看| 在线视频综合导航| 亚洲人成网站在线| 成人黄色网址在线观看| 久久久777精品电影网影网 | 99久久亚洲一区二区三区青草| 91精品国产品国语在线不卡| 亚洲精品久久久蜜桃| 高清国产一区二区三区| 久久女同性恋中文字幕| 精彩视频一区二区三区| 欧美肥大bbwbbw高潮| 亚洲自拍偷拍图区| 日本韩国欧美一区| 亚洲精品久久久蜜桃| 91免费视频大全| 国产精品另类一区| 成人av午夜电影| 国产精品久久久久久亚洲伦 | 欧美写真视频网站| 中文字幕中文字幕一区| 成人毛片老司机大片| 国产三级欧美三级日产三级99| 久久精品国产亚洲aⅴ| 日韩一区二区三区四区| 日本欧美大码aⅴ在线播放| 欧美高清精品3d| 日韩高清在线电影| 日韩精品一区二区三区中文不卡| 美女www一区二区| 久久综合九色综合97婷婷女人| 国产一区二区成人久久免费影院| 日韩精品中午字幕| 国内久久精品视频| 国产精品久久久久影院亚瑟| 成人精品亚洲人成在线| 亚洲欧美日韩一区| 欧美日韩一区二区三区视频| 三级成人在线视频| 亚洲精品在线三区| 国产成a人无v码亚洲福利| 国产精品久久久久久久久动漫| 日本韩国视频一区二区| 日本不卡一区二区三区高清视频| 欧美精品一区二区三区四区| 懂色av一区二区三区免费观看| 日韩伦理av电影| 欧美精品在线观看一区二区| 精品影视av免费| 1区2区3区欧美| 91精品国产欧美日韩| 久久er99精品| 国产欧美精品在线观看| 在线观看成人免费视频| 韩国女主播成人在线| 亚洲欧美日韩成人高清在线一区| 欧美精选一区二区| 不卡视频免费播放| 日韩成人av影视| 国产精品国产三级国产普通话99| 欧美三区在线观看| 国产sm精品调教视频网站| 亚洲电影一区二区三区| 久久精品视频在线看| 欧美日本韩国一区二区三区视频 | 91在线你懂得| 精品亚洲成av人在线观看| 亚洲欧美福利一区二区| 久久亚洲二区三区| 欧美日韩精品一二三区| www.欧美日韩国产在线| 日韩精品一级中文字幕精品视频免费观看| 久久久久久久久久看片| 91精品午夜视频| 99re热这里只有精品视频| 久久国产视频网| 久久精品久久精品| 亚洲最新在线观看| 精品国产亚洲在线| 色av一区二区| 亚洲国产精品t66y| 国产成人精品亚洲日本在线桃色| 69成人精品免费视频| 亚洲电影在线播放| 日韩午夜精品视频| 麻豆极品一区二区三区| 日韩欧美高清在线| 国产成人av影院| 亚洲免费资源在线播放| 色悠悠久久综合| 亚洲va欧美va国产va天堂影院| 在线电影院国产精品| 久久国产精品99精品国产| 91麻豆精品国产自产在线观看一区| 爽爽淫人综合网网站| 精品国内片67194| 成人av中文字幕| 国产高清不卡一区| 日韩精品亚洲专区| 亚洲一级二级在线| 国产精品久久久久久久久晋中 | 亚洲午夜电影在线观看| 欧美视频第二页| 亚洲午夜免费视频| 亚洲欧美色图小说| 亚洲欧美成aⅴ人在线观看| 亚洲免费在线电影| 亚洲制服丝袜在线| 亚欧色一区w666天堂| 日本欧洲一区二区| 五月天视频一区| 免费在线视频一区| 久久精品99久久久| 国产成人精品在线看| 成人免费视频caoporn| 成人sese在线| 欧美吻胸吃奶大尺度电影 | 2021久久国产精品不只是精品| 精品理论电影在线| 久久久电影一区二区三区| 国产清纯美女被跳蛋高潮一区二区久久w | 91亚洲精华国产精华精华液| 奇米影视一区二区三区小说| 一区二区三国产精华液| 成人免费一区二区三区在线观看| 久久伊99综合婷婷久久伊| 日韩欧美一区二区视频| 欧美tickling网站挠脚心| 日韩视频123| 欧美xfplay| 国产色一区二区| 亚洲精品成人悠悠色影视| 亚洲视频香蕉人妖| 日韩中文字幕亚洲一区二区va在线 | 欧美精品高清视频| 51精品国自产在线| 精品国产精品网麻豆系列| 久久夜色精品国产噜噜av| 亚洲天堂a在线| 日本欧美一区二区| 在线视频观看一区| 精品国产污网站| 曰韩精品一区二区| 狠狠色丁香婷综合久久| 国产成人免费在线观看不卡| 色综合色综合色综合| 日韩欧美激情在线| 欧美成人高清电影在线| 中文字幕在线观看一区二区| 亚洲永久免费av| 成人的网站免费观看| 91精品欧美福利在线观看|