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

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

?? os_mbox.c

?? 任務一 任務管理 任務二 優先級天花板 任務三 哲學家就餐 任務四 消息隊列 任務五 時鐘中斷
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                       MESSAGE MAILBOX MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_MBOX.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.h"
#endif

#if OS_MBOX_EN > 0
/*
*********************************************************************************************************
*                                     ACCEPT MESSAGE FROM MAILBOX
*
* Description: This function checks the mailbox to see if a message is available.  Unlike OSMboxPend(),
*              OSMboxAccept() 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 mailbox if one is available.  The mailbox is cleared
*                            so the next time OSMboxAccept() is called, the mailbox will be empty.
*              == (void *)0  if the mailbox is empty or,
*                            if 'pevent' is a NULL pointer or,
*                            if you didn't pass the proper event pointer.
*********************************************************************************************************
*/

#if OS_MBOX_ACCEPT_EN > 0
void  *OSMboxAccept (OS_EVENT *pevent)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif    
    void      *msg;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                        /* Validate 'pevent'                         */
        return ((void *)0);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {      /* Validate event block type                 */
        return ((void *)0);
    }
#endif
    OS_ENTER_CRITICAL();
    msg                = pevent->OSEventPtr;
    pevent->OSEventPtr = (void *)0;                       /* Clear the mailbox                         */
    OS_EXIT_CRITICAL();
    return (msg);                                         /* Return the message received (or NULL)     */
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
*                                        CREATE A MESSAGE MAILBOX
*
* Description: This function creates a message mailbox if free event control blocks are available.
*
* Arguments  : msg           is a pointer to a message that you wish to deposit in the mailbox.  If
*                            you set this value to the NULL pointer (i.e. (void *)0) then the mailbox
*                            will be considered empty.
*
* Returns    : != (OS_EVENT *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                                created mailbox
*              == (OS_EVENT *)0  if no event control blocks were available
*********************************************************************************************************
*/

OS_EVENT  *OSMboxCreate (void *msg)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_EVENT  *pevent;


    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) {
        pevent->OSEventType = OS_EVENT_TYPE_MBOX;
        pevent->OSEventCnt  = 0;
        pevent->OSEventPtr  = msg;               /* Deposit message in event control block             */
        OS_EventWaitListInit(pevent);
    }
    return (pevent);                             /* Return pointer to event control block              */
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                         DELETE A MAIBOX
*
* Description: This function deletes a mailbox and readies all tasks pending on the mailbox.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            mailbox.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete the mailbox ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the mailbox 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 mailbox was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the mailbox from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the mailbox
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a mailbox
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the mailbox was successfully deleted.
*
* Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
*                 the mailbox MUST check the return code of OSMboxPend().
*              2) OSMboxAccept() callers will not know that the intended mailbox has been deleted!
*              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 mailbox.
*              4) Because ALL tasks pending on the mailbox will be readied, you MUST be careful in
*                 applications where the mailbox is used for mutual exclusion because the resource(s)
*                 will no longer be guarded by the mailbox.
*********************************************************************************************************
*/

#if OS_MBOX_DEL_EN > 0
OS_EVENT  *OSMboxDel (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;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
#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_MBOX) {       /* 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 mailbox      */
        tasks_waiting = TRUE;                              /* Yes                                      */
    } else {
        tasks_waiting = FALSE;                             /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete mailbox only if no task waiting   */
             if (tasks_waiting == FALSE) {
                 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);                   /* Mailbox has been deleted                 */
             } else {
                 OS_EXIT_CRITICAL();
                 *err = OS_ERR_TASK_WAITING;
                 return (pevent);
             }

        case OS_DEL_ALWAYS:                                /* Always delete the mailbox                */
             while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for mailbox      */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MBOX);
             }
             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);                       /* Mailbox has been deleted                 */

        default:
             OS_EXIT_CRITICAL();
             *err = OS_ERR_INVALID_OPT;
             return (pevent);
    }
}
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                      PEND ON MAILBOX FOR A MESSAGE
*
* Description: This function waits for a message to be sent to a mailbox
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for a message to arrive at the mailbox up to the amount of time
*                            specified by this argument.  If you specify 0, however, your task will wait
*                            forever at the specified mailbox or, until a message arrives.
*
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_NO_ERR           The call was successful and your task received a
*                                                message.
*                            OS_TIMEOUT          A message was not received within the specified timeout
*                            OS_ERR_EVENT_TYPE   Invalid event type
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
*
* Returns    : != (void *)0  is a pointer to the message received
*              == (void *)0  if no message was received or,
*                            if 'pevent' is a NULL pointer or,
*                            if you didn't pass the proper pointer to the event control block.
*********************************************************************************************************
*/

void  *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif    
    void      *msg;


    if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
        *err = OS_ERR_PEND_ISR;                       /* ... can't PEND from an ISR                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国产精品区| 久久影院视频免费| 亚洲一线二线三线视频| 色婷婷综合久久久| 亚洲视频香蕉人妖| 色婷婷综合久色| 亚洲第一福利一区| 精品国产sm最大网站| 成人久久久精品乱码一区二区三区| 欧美国产精品久久| 在线免费观看一区| 日本aⅴ亚洲精品中文乱码| 日韩欧美一区中文| 91在线观看高清| 亚洲国产成人高清精品| 欧美精品一区二区高清在线观看| 国产一区二区在线免费观看| 亚洲天堂免费看| 精品一区二区在线免费观看| fc2成人免费人成在线观看播放| 亚洲福利视频导航| 欧美激情一区二区三区不卡| 精品国产精品一区二区夜夜嗨| 91精品国产高清一区二区三区蜜臀| 美日韩一区二区| 一个色在线综合| 久久久久国产精品人| 精品视频999| 国产成人一级电影| 夜夜夜精品看看| 国产日产欧美一区| 欧美一级片在线看| 欧美在线免费视屏| 91亚洲精品久久久蜜桃网站| 国产一区二区三区香蕉| 亚洲婷婷综合色高清在线| 精品免费99久久| 欧美一区二区精品| 久久婷婷久久一区二区三区| 成人激情小说网站| 久草精品在线观看| 男人的天堂亚洲一区| 日韩精品视频网| 日韩精品一区第一页| 亚洲国产精品综合小说图片区| 久久久久国产精品厨房| 欧美日韩视频一区二区| 91看片淫黄大片一级| 99久久久无码国产精品| 高清不卡一二三区| 成人黄色软件下载| 91最新地址在线播放| 成人黄色在线看| 99久久精品国产毛片| 成人免费三级在线| 波多野结衣欧美| 成人黄色av电影| 欧美在线999| 欧美一区二区三区免费| 亚洲天堂av老司机| 一区二区三区免费| 国内外精品视频| 色一情一乱一乱一91av| 精品入口麻豆88视频| 亚洲综合视频网| 国产一区免费电影| eeuss鲁片一区二区三区| 在线观看精品一区| 欧美sm极限捆绑bd| 一区二区在线观看视频| 极品少妇xxxx精品少妇偷拍| 色久综合一二码| xvideos.蜜桃一区二区| 亚洲乱码中文字幕| 国产精品456| 欧美日韩成人一区二区| 国产精品不卡在线观看| 蜜臀av性久久久久蜜臀aⅴ四虎| 成人国产精品免费| 国产欧美日韩亚州综合| 中文字幕乱码一区二区免费| 亚洲电影一级黄| 色综合久久综合网97色综合| 欧美激情中文不卡| 91色porny| 国产欧美精品一区aⅴ影院| 另类专区欧美蜜桃臀第一页| 欧美日韩五月天| 午夜精品免费在线| 色妞www精品视频| 亚洲男女毛片无遮挡| heyzo一本久久综合| 亚洲国产精品高清| 国产成人综合视频| 国产精品污网站| 99国产精品一区| 综合网在线视频| 在线亚洲+欧美+日本专区| 亚洲日本免费电影| 欧美亚洲国产一区在线观看网站| 亚洲国产综合视频在线观看| 欧美午夜精品一区二区三区| 一区二区三区四区亚洲| 欧美日韩综合在线| 另类综合日韩欧美亚洲| 国产日韩欧美制服另类| 99国产麻豆精品| 午夜电影网一区| 精品久久久久久久人人人人传媒| 国产成人av电影在线| 中文字幕在线观看不卡| 欧美日韩国产免费| 国产精品88av| 午夜国产不卡在线观看视频| 日韩欧美黄色影院| 99国产精品国产精品久久| 日韩av在线播放中文字幕| 2020日本不卡一区二区视频| 色综合久久精品| 国产中文字幕精品| 亚洲成av人片一区二区| 欧美影片第一页| 国产在线精品一区二区不卡了 | 欧美国产一区视频在线观看| av网站免费线看精品| 加勒比av一区二区| 亚洲人一二三区| 欧美国产国产综合| 精品成a人在线观看| 欧美日韩的一区二区| 北条麻妃国产九九精品视频| 精一区二区三区| 夜夜夜精品看看| 国产精品视频一区二区三区不卡| 欧美一区二区三区在| 99久久99久久久精品齐齐| 国产成a人亚洲| 国模套图日韩精品一区二区| 亚洲福利电影网| 午夜欧美视频在线观看| 亚洲婷婷在线视频| 亚洲国产高清不卡| 久久久久久久综合狠狠综合| 日韩三级视频在线看| 欧美精品v日韩精品v韩国精品v| 在线观看国产91| 欧美日韩精品综合在线| 精品视频在线免费| 欧美日韩黄视频| 欧美男生操女生| 欧美一区二区黄| 欧美不卡在线视频| 久久精品人人做人人综合 | 不卡的电影网站| 国产成人免费高清| 不卡视频免费播放| av中文字幕在线不卡| 91蜜桃视频在线| 欧美色综合天天久久综合精品| 波多野结衣视频一区| 欧美性欧美巨大黑白大战| 欧美日韩国产天堂| 久久综合成人精品亚洲另类欧美 | 亚洲美女少妇撒尿| 亚洲精品乱码久久久久久日本蜜臀| 国产精品久久久一本精品| 亚洲成av人影院在线观看网| 日本欧洲一区二区| zzijzzij亚洲日本少妇熟睡| 欧美日韩中文字幕一区二区| 日韩精品一区二区在线| 国产精品丝袜黑色高跟| 免费在线观看日韩欧美| 夫妻av一区二区| 91精品久久久久久蜜臀| 久久久久97国产精华液好用吗| 亚洲人成小说网站色在线 | 日本欧美大码aⅴ在线播放| 国产黄色成人av| 欧美中文字幕一区| 日本一区二区三区四区| 日本免费在线视频不卡一不卡二| 欧美剧情片在线观看| 亚洲国产精品黑人久久久| 免费xxxx性欧美18vr| 91麻豆123| 国产精品久久久久影院老司 | 裸体一区二区三区| 欧美午夜不卡在线观看免费| 国产视频一区二区在线观看| 蜜桃传媒麻豆第一区在线观看| 日本黄色一区二区| 亚洲欧洲av一区二区三区久久| 国产精品亚洲午夜一区二区三区| 欧美亚洲综合色| 亚洲激情第一区| 色婷婷综合五月| 亚洲午夜激情网页| 欧美高清一级片在线| 亚洲与欧洲av电影|