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

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

?? os_q.c

?? 飛思卡爾HCS12的OS移植(ucosII),實現了三個任務,IDE:CODEWARRIOR
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                        MESSAGE QUEUE MANAGEMENT
*
*                              (c) Copyright 1992-2007, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_Q.C
* By      : Jean J. Labrosse
* Version : V2.86
*
* LICENSING TERMS:
* ---------------
*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
* If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
* its use in your product. We provide ALL the source code for your convenience and to help you experience 
* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
* licensing fee.
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include <ucos_ii.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
*
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_ERR_NONE         The call was successful and your task received a
*                                                message.
*                            OS_ERR_EVENT_TYPE   You didn't pass a pointer to a queue
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
*                            OS_ERR_Q_EMPTY      The queue did not contain any messages
*
* 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 you received a NULL pointer message
*                            if the queue is empty or,
*                            if 'pevent' is a NULL pointer or,
*                            if you passed an invalid event type
*
* Note(s)    : As of V2.60, you can now pass NULL pointers through queues.  Because of this, the argument
*              'perr' has been added to the API to tell you about the outcome of the call.
*********************************************************************************************************
*/

#if OS_Q_ACCEPT_EN > 0
void  *OSQAccept (OS_EVENT *pevent, INT8U *perr)
{
    void      *pmsg;
    OS_Q      *pq;
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                    /* Validate 'perr'                                    */
        return ((void *)0);
    }
    if (pevent == (OS_EVENT *)0) {               /* Validate 'pevent'                                  */
        *perr = OS_ERR_PEVENT_NULL;
        return ((void *)0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type                          */
        *perr = OS_ERR_EVENT_TYPE;
        return ((void *)0);
    }
    OS_ENTER_CRITICAL();
    pq = (OS_Q *)pevent->OSEventPtr;             /* Point at queue control block                       */
    if (pq->OSQEntries > 0) {                    /* See if any messages in the queue                   */
        pmsg = *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;
        }
        *perr = OS_ERR_NONE;
    } else {
        *perr = OS_ERR_Q_EMPTY;
        pmsg  = (void *)0;                       /* Queue is empty                                     */
    }
    OS_EXIT_CRITICAL();
    return (pmsg);                               /* 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 OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr = 0;
#endif



    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;
#if OS_EVENT_NAME_SIZE > 1
            pevent->OSEventName[0] = '?';                  /* Unknown name                             */
            pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
            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.
*
*              perr          is a pointer to an error code that can contain one of the following values:
*                            OS_ERR_NONE             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 *perr)
{
    BOOLEAN    tasks_waiting;
    OS_EVENT  *pevent_return;
    OS_Q      *pq;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                              /* Validate 'perr'                          */
        return (pevent);
    }
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *perr = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {          /* Validate event block type                */
        *perr = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *perr = OS_ERR_DEL_ISR;                            /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on queue        */
        tasks_waiting = OS_TRUE;                           /* Yes                                      */
    } else {
        tasks_waiting = OS_FALSE;                          /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete queue only if no task waiting     */
             if (tasks_waiting == OS_FALSE) {
#if OS_EVENT_NAME_SIZE > 1
                 pevent->OSEventName[0] = '?';             /* Unknown name                             */
                 pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
                 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  */
                 pevent->OSEventCnt     = 0;
                 OSEventFreeList        = pevent;          /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *perr                  = OS_ERR_NONE;
                 pevent_return          = (OS_EVENT *)0;   /* Queue has been deleted                   */
             } else {
                 OS_EXIT_CRITICAL();
                 *perr                  = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the queue                  */
             while (pevent->OSEventGrp != 0) {             /* Ready ALL tasks waiting for queue        */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_Q, OS_STAT_PEND_OK);
             }
#if OS_EVENT_NAME_SIZE > 1
             pevent->OSEventName[0] = '?';                 /* Unknown name                             */
             pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
             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  */
             pevent->OSEventCnt     = 0;
             OSEventFreeList        = pevent;              /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == OS_TRUE) {               /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *perr                  = OS_ERR_NONE;
             pevent_return          = (OS_EVENT *)0;       /* Queue has been deleted                   */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产精品亚洲红杏 | 国产色91在线| 久久精品国产秦先生| 欧美一区二区三区视频免费播放 | 久久欧美一区二区| 国产在线视频一区二区| 久久久精品免费网站| 9色porny自拍视频一区二区| 婷婷综合另类小说色区| 欧美一卡二卡三卡四卡| 精品一区二区三区香蕉蜜桃| 国产精品乱码妇女bbbb| 99久久免费精品| 日韩电影在线一区二区三区| 久久先锋资源网| 91色综合久久久久婷婷| 亚洲高清一区二区三区| 精品国产乱码久久久久久1区2区| 成人午夜视频在线观看| 一区二区三区 在线观看视频| 欧美一区二区三区免费| 国内精品国产成人国产三级粉色| 中文字幕永久在线不卡| 欧美色图在线观看| 国产乱子伦视频一区二区三区 | 中文字幕一区二区不卡| 精品视频资源站| 国产一区二区电影| 亚洲国产毛片aaaaa无费看| 亚洲精品一区二区三区在线观看| av一区二区三区在线| 日韩av在线播放中文字幕| 欧美国产一区二区在线观看| 欧美三级电影在线看| 韩国成人在线视频| 亚洲成人在线观看视频| 欧美高清在线精品一区| 日韩视频在线永久播放| 97se亚洲国产综合自在线 | 国内精品写真在线观看| 一区二区三区中文免费| 久久在线观看免费| 欧美精品一二三四| 色八戒一区二区三区| 国产毛片精品视频| 喷水一区二区三区| 一二三四社区欧美黄| 中文字幕乱码一区二区免费| 欧美一区二区三区日韩视频| 色久综合一二码| 大胆欧美人体老妇| 91女厕偷拍女厕偷拍高清| 极品瑜伽女神91| 水野朝阳av一区二区三区| 亚洲色图欧美激情| 国产欧美视频一区二区| 精品国产一区二区三区四区四| 在线免费视频一区二区| 91免费观看在线| 成人国产一区二区三区精品| 国产另类ts人妖一区二区| 免费在线观看视频一区| 日韩—二三区免费观看av| 香港成人在线视频| 亚洲美女精品一区| 亚洲精品日韩综合观看成人91| 国产精品每日更新| 国产精品成人一区二区艾草| 中文字幕av不卡| 欧美国产丝袜视频| 国产精品日日摸夜夜摸av| 久久精品视频免费| 国产女主播在线一区二区| 国产午夜精品美女毛片视频| 精品日韩一区二区三区| 精品日韩一区二区| 久久综合五月天婷婷伊人| 精品久久五月天| 久久精子c满五个校花| 欧美极品美女视频| 国产精品天干天干在线综合| 国产精品天干天干在观线| 中文字幕一区二区日韩精品绯色 | 亚洲欧美综合网| 亚洲素人一区二区| 亚洲欧美日韩国产另类专区 | 亚洲激情综合网| 亚洲福利一区二区三区| 日韩激情av在线| 狠狠色狠狠色综合| 成人福利视频在线看| 99r国产精品| 欧美日韩精品欧美日韩精品一综合| 欧美日韩国产在线播放网站| 日韩欧美美女一区二区三区| 国产亚洲一区二区三区四区 | 一区二区三区国产豹纹内裤在线 | 日韩视频在线一区二区| 久久综合九色综合欧美98| 国产精品久久99| 亚洲国产cao| 国产制服丝袜一区| 色久优优欧美色久优优| 日韩一区二区电影在线| 中文字幕电影一区| 亚洲一区二区欧美激情| 韩国av一区二区三区四区| 91一区二区三区在线观看| 欧美狂野另类xxxxoooo| 国产农村妇女毛片精品久久麻豆| 久久国产尿小便嘘嘘尿| 国产99一区视频免费| 91成人国产精品| 久久人人97超碰com| 一区二区三区在线不卡| 久久精品国产一区二区| 91浏览器在线视频| 日韩欧美亚洲一区二区| 最新不卡av在线| 老司机免费视频一区二区| 91丨porny丨国产| 日韩视频中午一区| 夜夜爽夜夜爽精品视频| 国产一区二区三区视频在线播放| 欧美午夜在线观看| 日本一区二区动态图| 免费人成网站在线观看欧美高清| 97久久精品人人做人人爽50路| 欧美一区二区三区日韩| 亚洲你懂的在线视频| 国产原创一区二区三区| 欧美性色aⅴ视频一区日韩精品| 精品国产伦理网| 午夜欧美电影在线观看| av中文字幕在线不卡| 精品久久久久久久久久久久久久久久久 | 一个色妞综合视频在线观看| 午夜久久久影院| 91浏览器打开| 国产亚洲午夜高清国产拍精品| 亚洲成av人片在线观看| 91丨九色丨黑人外教| 国产午夜三级一区二区三| 天天免费综合色| 日本丰满少妇一区二区三区| 久久久久国产精品麻豆| 久久国产免费看| 欧美精品亚洲二区| 悠悠色在线精品| 91麻豆免费看片| 国产精品你懂的| 国产91丝袜在线18| 亚洲精品一区二区三区蜜桃下载| 日韩高清电影一区| 精品视频123区在线观看| 亚洲精品你懂的| 99久久国产综合精品麻豆| 久久久久国产精品厨房| 国产在线播放一区三区四| 日韩美女视频在线| 男男视频亚洲欧美| 日韩视频一区在线观看| 免费三级欧美电影| 欧美一区二区观看视频| 免费成人av在线播放| 欧美一级片免费看| 美日韩黄色大片| 日韩一区二区三区视频在线| 亚洲mv在线观看| 91精品国产欧美一区二区18 | 另类小说视频一区二区| 欧美一级在线视频| 久久99精品国产91久久来源| 日韩精品一区二区在线| 久久国产精品72免费观看| 久久亚洲免费视频| 国产福利电影一区二区三区| 久久久久国产一区二区三区四区| 国产成人av电影在线播放| 日本一区二区久久| 91麻豆免费在线观看| 亚洲电影在线播放| 欧美美女喷水视频| 欧美a级理论片| 国产午夜亚洲精品理论片色戒| 国产成人av一区二区| 久久99精品一区二区三区 | 欧美三级乱人伦电影| 五月天亚洲精品| 久久综合精品国产一区二区三区| 国产精品系列在线播放| 国产精品盗摄一区二区三区| 91成人国产精品| 青娱乐精品在线视频| 2020国产精品自拍| 91视频在线观看| 午夜精品久久久久久久| 久久久蜜臀国产一区二区| 日本电影亚洲天堂一区| 日本成人在线视频网站|