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

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

?? os_q.c

?? 基于uCOS-II的串口驅動(用Keil C)
?? 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)
{

    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)
{

    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)
{

    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一区二区三区免费野_久草精品视频
欧美日韩激情一区二区| 亚洲欧美国产77777| 亚洲欧美激情一区二区| 国产一区高清在线| 久久久精品日韩欧美| 午夜精彩视频在线观看不卡| 不卡一区二区三区四区| 久久综合九色综合97婷婷女人 | 99久久精品国产麻豆演员表| 欧美高清视频在线高清观看mv色露露十八 | 国产精品77777| 日韩一区二区在线观看视频 | 国产精品色哟哟网站| 免费黄网站欧美| 欧美午夜在线观看| 亚洲视频一区二区在线| 成人白浆超碰人人人人| 久久久精品影视| 国产在线看一区| 久久综合色8888| 精品一区二区三区久久| 欧美成人艳星乳罩| 麻豆专区一区二区三区四区五区| 欧美性生活一区| 性做久久久久久免费观看欧美| 一本高清dvd不卡在线观看| 国产精品高潮呻吟| caoporen国产精品视频| 五月天久久比比资源色| 欧美日韩高清一区二区| 亚洲高清免费在线| 制服丝袜中文字幕一区| 日韩国产精品91| 6080国产精品一区二区| 免费一级欧美片在线观看| 日韩亚洲欧美中文三级| 久久国产精品99久久人人澡| 亚洲精品一区二区精华| 国产精品自拍在线| 国产亚洲精品超碰| 不卡av在线免费观看| 一区二区三区在线观看网站| 精品视频在线视频| 美女被吸乳得到大胸91| 国产人久久人人人人爽| 成人性生交大片免费| 中文字幕制服丝袜一区二区三区 | 国产麻豆视频一区二区| 国产亚洲成年网址在线观看| 波多野结衣欧美| 一区二区三区在线播放| 7777精品伊人久久久大香线蕉经典版下载| 日韩制服丝袜先锋影音| 久久久亚洲精华液精华液精华液| 成人一区二区三区| 一区二区三区在线不卡| 精品区一区二区| 成人激情动漫在线观看| 亚洲一二三四在线| 2023国产精华国产精品| 色94色欧美sute亚洲线路一ni| 亚洲精品日韩一| 日韩免费看的电影| 91在线精品秘密一区二区| 天使萌一区二区三区免费观看| 久久亚洲精精品中文字幕早川悠里| 国产91精品入口| 亚洲va天堂va国产va久| 国产三级欧美三级日产三级99| 91色|porny| 精品一区二区久久久| 亚洲曰韩产成在线| 久久精品视频一区| 欧美精品18+| 91亚洲国产成人精品一区二区三 | 国产免费成人在线视频| 欧美日韩中文精品| 成人av免费网站| 久久99国产精品久久| 亚洲一区二区三区爽爽爽爽爽| 2020国产精品久久精品美国| 欧美日韩国产综合久久| 国产成人av电影| 麻豆成人免费电影| 一区二区三区加勒比av| 国产精品久久久久久久久免费丝袜 | 欧美精品久久99| 不卡av在线网| 懂色av一区二区三区蜜臀| 视频精品一区二区| 亚洲一卡二卡三卡四卡五卡| 国产精品护士白丝一区av| 欧美成人一级视频| 日韩午夜激情av| 欧美午夜精品免费| 91麻豆成人久久精品二区三区| 国模套图日韩精品一区二区| 偷拍一区二区三区四区| 国模大尺度一区二区三区| 性做久久久久久久免费看| 亚洲精品久久久久久国产精华液| 国产精品欧美一级免费| 久久精品一区二区三区四区| 久久影院视频免费| 精品国产区一区| 欧美一区二区三区免费在线看 | 欧美在线观看视频一区二区三区| 成人教育av在线| 国产99一区视频免费| 国产精品一级黄| 国产成人在线影院| 国产成人免费9x9x人网站视频| 国产精品综合一区二区三区| 久久99精品久久久久| 久久超碰97中文字幕| 国内欧美视频一区二区| 国产精品一二三在| 丰满放荡岳乱妇91ww| www.在线欧美| 色婷婷综合在线| 欧美天堂亚洲电影院在线播放| 欧美亚洲综合在线| 欧美三级在线播放| 欧美变态凌虐bdsm| 欧美精品一区二区三区在线 | 成人免费高清在线| eeuss鲁片一区二区三区在线观看| 99免费精品在线观看| 91成人在线免费观看| 欧美精品自拍偷拍| 日韩女优毛片在线| 国产精品三级视频| 一区二区三区在线观看动漫| 视频一区中文字幕| 国产综合色视频| jlzzjlzz欧美大全| 欧美日韩亚洲另类| 亚洲一区二区五区| 日本视频在线一区| 粉嫩在线一区二区三区视频| 日本道精品一区二区三区| 51精品国自产在线| 久久先锋资源网| 亚洲女爱视频在线| 日本va欧美va精品| 成人黄色在线视频| 在线电影欧美成精品| 国产欧美精品区一区二区三区| 日韩一区在线免费观看| 日本不卡高清视频| 91天堂素人约啪| 欧美成va人片在线观看| 中文字幕日韩一区| 精品一区二区免费在线观看| 色网综合在线观看| 精品国产91洋老外米糕| 亚洲精品写真福利| 精品一区二区三区在线视频| 色综合色综合色综合| 精品久久国产字幕高潮| 亚洲午夜精品在线| 成人久久18免费网站麻豆| 欧美日韩国产精品自在自线| 久久免费的精品国产v∧| 亚洲成人免费av| 成人高清免费在线播放| 精品三级在线观看| 五月天网站亚洲| 色综合一个色综合| 国产欧美日韩另类一区| 久久精品久久99精品久久| 在线观看www91| 一区在线中文字幕| 国产99久久久国产精品免费看| 8x福利精品第一导航| 亚洲欧美二区三区| 99久久免费视频.com| 久久蜜桃av一区精品变态类天堂 | 亚洲人成伊人成综合网小说| 狠狠色狠狠色综合日日91app| 欧美视频在线不卡| 亚洲欧洲国产日韩| 成人免费视频播放| 亚洲国产高清不卡| 国产福利一区在线观看| 精品日韩一区二区三区| 日韩精品一级二级 | 美日韩黄色大片| 91麻豆精品国产综合久久久久久| 一区二区三区高清| 欧美最新大片在线看 | 久久久亚洲欧洲日产国码αv| 日韩福利电影在线观看| 欧美日韩国产一级二级| 亚洲一区二区在线免费观看视频| 欧美综合色免费| 亚洲午夜羞羞片| 欧美日韩一级大片网址| 日韩成人伦理电影在线观看| 日韩午夜中文字幕|