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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_q.c

?? 強人寫的UCOS_II,V2.52
?? 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();

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产乱码久久久久久图片| 国产精品成人免费| 91在线视频观看| 国产精品自在欧美一区| 精彩视频一区二区三区| 91视频免费观看| 欧美国产一区在线| 欧美大片日本大片免费观看| 26uuu亚洲综合色欧美| 91精品国产91久久久久久一区二区| 欧美三级电影网站| 欧美群妇大交群中文字幕| 欧美日韩精品系列| 精品日产卡一卡二卡麻豆| 精品日产卡一卡二卡麻豆| 国产女人水真多18毛片18精品视频| 国产亚洲精品超碰| 亚洲欧美偷拍卡通变态| 亚洲福利一区二区| 久久国产日韩欧美精品| 国产一区二区在线观看免费| 国产激情视频一区二区三区欧美| 国产 欧美在线| 91福利在线观看| 日韩欧美123| 国产精品不卡一区二区三区| 一区二区三区在线免费播放| 日本成人在线电影网| 国产自产高清不卡| 一本久道久久综合中文字幕| 欧美男男青年gay1069videost | 日本女优在线视频一区二区| 麻豆免费看一区二区三区| 精品系列免费在线观看| 中国色在线观看另类| 亚洲同性gay激情无套| 亚欧色一区w666天堂| 国产在线精品一区二区不卡了| 成人av动漫网站| 91精品国产综合久久香蕉的特点 | 99久久精品国产麻豆演员表| 91亚洲国产成人精品一区二区三 | 美女一区二区三区| av一区二区三区在线| 91精品在线观看入口| 中文字幕一区在线观看视频| 蜜桃av一区二区| 色狠狠综合天天综合综合| 26uuu亚洲综合色| 亚欧色一区w666天堂| 精品久久久久久久久久久院品网| 日韩一本二本av| 亚洲免费观看视频| 国产又粗又猛又爽又黄91精品| 日本韩国视频一区二区| 国产日韩欧美在线一区| 美女脱光内衣内裤视频久久影院| 一本一本大道香蕉久在线精品| 2024国产精品| 蜜臀va亚洲va欧美va天堂| 91久久精品日日躁夜夜躁欧美| 国产亚洲精品久| 激情小说欧美图片| 91精品国产入口| 亚洲不卡一区二区三区| 欧洲国产伦久久久久久久| 亚洲欧洲三级电影| 成人手机电影网| 国产情人综合久久777777| 精品一区二区三区久久| 日韩美女一区二区三区四区| 日韩国产欧美三级| 中文字幕av资源一区| 亚洲一区二区三区四区五区黄| 成人精品鲁一区一区二区| 久久久久国产精品厨房| 麻豆一区二区在线| 日韩视频国产视频| 久久精品国产第一区二区三区| 欧美年轻男男videosbes| 亚洲高清免费观看高清完整版在线观看| 粉嫩av一区二区三区| 日本一区二区三区dvd视频在线| 国产一区二区三区日韩| 久久久久久久网| 成人一区二区视频| 成人欧美一区二区三区视频网页| 丁香六月综合激情| 成人欧美一区二区三区白人| 91亚洲精品久久久蜜桃网站| 亚洲一区二区在线免费看| 欧美精选一区二区| 美女一区二区在线观看| 国产三级久久久| 色偷偷成人一区二区三区91| 亚洲aaa精品| 精品国精品自拍自在线| 国产成人av电影在线播放| 亚洲欧美精品午睡沙发| 欧美男人的天堂一二区| 精品综合免费视频观看| 国产精品麻豆久久久| 色国产综合视频| 久久99久久99小草精品免视看| 久久亚洲欧美国产精品乐播| 成人黄色a**站在线观看| 樱花影视一区二区| 欧美一级欧美三级在线观看| 国产一区在线看| 亚洲精品久久7777| 精品久久99ma| 在线观看av一区二区| 美女国产一区二区三区| 国产精品美女一区二区三区| 欧美精品一区二区三区久久久| 国产91丝袜在线18| 天天色综合成人网| 国产精品色呦呦| 日韩欧美一区二区视频| 色综合视频在线观看| 久久成人羞羞网站| 亚洲国产cao| 中文字幕第一区综合| 日韩一级高清毛片| 在线精品视频一区二区| 福利91精品一区二区三区| 午夜影院久久久| 亚洲色图在线播放| 国产日产亚洲精品系列| 宅男在线国产精品| 在线一区二区三区四区| 国产精品资源在线| 乱一区二区av| 偷窥少妇高潮呻吟av久久免费| 国产精品国产三级国产aⅴ原创 | 中文字幕日韩一区| 日韩美女视频在线| 欧美男同性恋视频网站| 91九色最新地址| k8久久久一区二区三区| 国产在线精品免费av| 麻豆精品一区二区三区| 午夜精品久久久久久久99水蜜桃| **欧美大码日韩| 国产日韩精品视频一区| 精品精品国产高清a毛片牛牛| 6080午夜不卡| 欧美精品三级在线观看| 精品视频一区二区不卡| 在线观看不卡一区| 欧美性猛片aaaaaaa做受| 97国产一区二区| 97精品久久久午夜一区二区三区| 成人丝袜高跟foot| 懂色av一区二区在线播放| 国产精品一区二区三区网站| 久久99精品久久只有精品| 久久国产精品露脸对白| 九九九精品视频| 国产乱子轮精品视频| 国产精品一二三四| 国产成人av网站| 99国产一区二区三精品乱码| 91在线观看高清| 在线视频国内一区二区| 欧美日韩中文字幕一区| 在线播放中文字幕一区| 91精品国产美女浴室洗澡无遮挡| 欧美一区二区三区在| 日韩欧美一二三区| 国产亚洲欧美日韩俺去了| 亚洲国产高清在线观看视频| 中文字幕一区二区日韩精品绯色| 亚洲黄色免费网站| 日日欢夜夜爽一区| 国产精品自拍三区| 91麻豆福利精品推荐| 欧美巨大另类极品videosbest | 欧美日韩一区二区欧美激情| 欧美综合亚洲图片综合区| 在线不卡一区二区| 精品处破学生在线二十三| 中文欧美字幕免费| 一区二区三区高清在线| 麻豆成人免费电影| yourporn久久国产精品| 欧美三级电影在线看| 久久人人超碰精品| 一区二区在线观看视频在线观看| 日韩福利电影在线| 高清成人免费视频| 欧美欧美欧美欧美首页| 中文字幕国产精品一区二区| 日韩二区三区在线观看| 成人免费高清视频| 91麻豆精品久久久久蜜臀| 国产精品理论在线观看| 奇米色一区二区三区四区| 成人av在线电影| 日韩亚洲欧美在线|