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

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

?? os_mbox.c

?? UC/OS的例子希望對大家有用
?? 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一区二区三区免费野_久草精品视频
久久精品亚洲国产奇米99| 色噜噜夜夜夜综合网| 日韩一区二区三区免费观看| 亚洲一级不卡视频| 欧美羞羞免费网站| 亚洲成在线观看| 日韩三级视频在线看| 狠狠色综合播放一区二区| 日本一区二区三区dvd视频在线| 国产福利视频一区二区三区| 国产精品乱码人人做人人爱| 色视频欧美一区二区三区| 亚洲大型综合色站| 久久网站热最新地址| 成人av免费在线| 亚洲国产精品久久久久秋霞影院| 6080yy午夜一二三区久久| 极品少妇xxxx精品少妇| 国产女人aaa级久久久级| 色综合视频在线观看| 日本免费新一区视频| 久久久精品国产免费观看同学| 92精品国产成人观看免费| 午夜精品久久久久久久久久久| 91精品国产福利在线观看| 国产高清亚洲一区| 亚洲综合色网站| 国产亚洲午夜高清国产拍精品| 97久久超碰国产精品| 免费久久99精品国产| 国产精品初高中害羞小美女文| 欧美日本在线一区| 成人涩涩免费视频| 日韩国产一二三区| 成人欧美一区二区三区1314| 宅男噜噜噜66一区二区66| 成人激情免费网站| 免费高清视频精品| 亚洲美女屁股眼交| 久久亚洲一区二区三区四区| 国产99一区视频免费| 久久久亚洲精华液精华液精华液| 欧美日韩精品电影| 亚洲卡通欧美制服中文| 欧美v亚洲v综合ⅴ国产v| 91女人视频在线观看| 奇米精品一区二区三区在线观看 | 亚洲第一久久影院| 国产日韩欧美一区二区三区综合| 欧美日韩一区二区在线观看视频| 高清不卡在线观看| 韩国一区二区在线观看| 亚洲第一会所有码转帖| 亚洲欧美二区三区| 中文字幕+乱码+中文字幕一区| 7777精品伊人久久久大香线蕉经典版下载 | 91精品国产aⅴ一区二区| 91偷拍与自偷拍精品| 国产成人亚洲精品狼色在线| 青青青爽久久午夜综合久久午夜 | eeuss鲁一区二区三区| 经典三级视频一区| 免费成人在线播放| 亚洲大型综合色站| 一卡二卡三卡日韩欧美| 中文字幕日韩av资源站| 亚洲国产精品精华液ab| 国产亚洲精品免费| 久久精品一区二区三区不卡牛牛| 欧美一区二区精品在线| 欧美情侣在线播放| 欧美伦理视频网站| 欧美日韩综合在线免费观看| 色噜噜夜夜夜综合网| 色综合天天综合| 91捆绑美女网站| 一本大道久久a久久精品综合 | 色av成人天堂桃色av| 94-欧美-setu| 欧美中文字幕一区二区三区 | 人人狠狠综合久久亚洲| 午夜精品一区二区三区免费视频| 亚洲第一av色| 蜜桃av一区二区| 久久99热狠狠色一区二区| 久久精品国产久精国产爱| 久久99久久精品| 国产成人在线视频网址| 成人成人成人在线视频| 91麻豆视频网站| 欧美日韩性生活| 欧美一区二区三区播放老司机| 91精品国产品国语在线不卡 | 久久中文娱乐网| 欧美国产激情一区二区三区蜜月| 国产精品不卡在线观看| 亚洲欧美激情小说另类| 亚洲午夜激情av| 久久99精品久久久久久| 国产福利91精品| 色综合一个色综合亚洲| 欧美夫妻性生活| 久久久国产精华| 依依成人精品视频| 人人狠狠综合久久亚洲| 国产一区二区三区久久悠悠色av| voyeur盗摄精品| 欧美日韩精品免费观看视频 | 国产激情视频一区二区三区欧美| 99精品欧美一区二区三区小说 | 亚洲不卡在线观看| 美腿丝袜一区二区三区| 97se亚洲国产综合在线| 91精品国产手机| 国产色产综合色产在线视频| 亚洲美女视频在线观看| 理论片日本一区| 91麻豆高清视频| 亚洲精品一线二线三线无人区| 中文字幕精品一区二区精品绿巨人| 一区二区三区中文在线观看| 秋霞电影一区二区| 99久久婷婷国产精品综合| 日韩欧美在线1卡| 亚洲私人影院在线观看| 麻豆精品视频在线观看| 在线观看国产91| 久久精品视频一区二区三区| 一区二区在线观看不卡| 国产精品538一区二区在线| 欧美视频一二三区| 国产精品欧美一区二区三区| 日本女人一区二区三区| 91亚洲精品久久久蜜桃网站| 久久中文娱乐网| 婷婷六月综合亚洲| 色综合色综合色综合色综合色综合| 欧美成人免费网站| 天天爽夜夜爽夜夜爽精品视频 | 91免费国产在线观看| 久久一日本道色综合| 日韩黄色片在线观看| 91麻豆自制传媒国产之光| 久久久噜噜噜久噜久久综合| 日本美女一区二区| 在线精品视频免费观看| 亚洲欧洲99久久| 成人免费视频国产在线观看| 欧美xxxx老人做受| 日本免费在线视频不卡一不卡二| 欧美性xxxxxxxx| 亚洲九九爱视频| 99精品国产99久久久久久白柏 | 99视频精品在线| 国产精品午夜免费| 国产精品亚洲а∨天堂免在线| 日韩欧美视频一区| 日日骚欧美日韩| 欧美日韩免费一区二区三区| 亚洲精品va在线观看| 色国产综合视频| 一区二区三区在线视频观看| 色哟哟一区二区| 亚洲欧美福利一区二区| 色综合视频一区二区三区高清| 亚洲人123区| 色噜噜狠狠成人中文综合 | 久久久夜色精品亚洲| 韩国欧美一区二区| 久久久久久久网| 国产成人免费视频| 欧美国产97人人爽人人喊| 成人爽a毛片一区二区免费| 国产精品视频一二三| 成人的网站免费观看| 亚洲日本中文字幕区| 在线观看成人免费视频| 午夜不卡av在线| 日韩视频一区二区在线观看| 老色鬼精品视频在线观看播放| 欧美不卡一区二区| 国产传媒久久文化传媒| 国产亚洲成av人在线观看导航| 国产成人av福利| 亚洲日本成人在线观看| 91国在线观看| 婷婷激情综合网| 精品嫩草影院久久| 国产91高潮流白浆在线麻豆| 亚洲视频中文字幕| 欧美女孩性生活视频| 美女视频一区二区三区| 国产亚洲精品7777| 日本韩国一区二区三区视频| 五月天中文字幕一区二区| 日韩一区二区在线免费观看| 国产一区中文字幕| 亚洲老司机在线| 欧美一卡在线观看| 岛国一区二区在线观看|