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

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

?? os_mbox.c

?? 講UC/OS的書
?? C
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                       MESSAGE MAILBOX MANAGEMENT
*
*                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
*                                           All Rights Reserved
*
*                                                  V2.00
*
* File : OS_MBOX.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

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

#if OS_MBOX_EN
/*
*********************************************************************************************************
*                                     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 you didn't pass the proper event pointer.
*********************************************************************************************************
*/

void *OSMboxAccept (OS_EVENT *pevent)
{
    void  *msg;


    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {      /* Validate event block type                 */
        OS_EXIT_CRITICAL();
        return ((void *)0);
    }
    msg = pevent->OSEventPtr; 
    if (msg != (void *)0) {                               /* See if there is already a message         */
        pevent->OSEventPtr = (void *)0;                   /* Clear the mailbox                         */
    }
    OS_EXIT_CRITICAL();
    return (msg);                                         /* Return the message received (or NULL)     */
}
/*$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    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                            created mailbox
*              == (void *)0  if no event control blocks were available
*********************************************************************************************************
*/

OS_EVENT *OSMboxCreate (void *msg)
{
    OS_EVENT *pevent;


    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->OSEventPtr  = msg;               /* Deposit message in event control block             */
        OSEventWaitListInit(pevent);
    }
    return (pevent);                             /* Return pointer to event control block              */
}
/*$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.
*
* Returns    : != (void *)0  is a pointer to the message received
*              == (void *)0  if no message was received or you didn't pass the proper pointer to the
*                            event control block.
*********************************************************************************************************
*/

void *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
{
    void  *msg;


    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        *err = OS_ERR_EVENT_TYPE;
        return ((void *)0);
    }
    msg = pevent->OSEventPtr;
    if (msg != (void *)0) {                           /* See if there is already a message             */
        pevent->OSEventPtr = (void *)0;               /* Clear the mailbox                             */
        OS_EXIT_CRITICAL();
        *err = OS_NO_ERR;
    } else if (OSIntNesting > 0) {                    /* See if called from ISR ...                    */
        OS_EXIT_CRITICAL();                           /* ... can't PEND from an ISR                    */
        *err = OS_ERR_PEND_ISR;
    } else {
        OSTCBCur->OSTCBStat |= OS_STAT_MBOX;          /* Message not available, task will pend         */
        OSTCBCur->OSTCBDly   = timeout;               /* Load timeout in TCB                           */
        OSEventTaskWait(pevent);                      /* Suspend task until event or timeout occurs    */
        //OS_EXIT_CRITICAL();
        OSSched();
        OS_EXIT_CRITICAL();                                    /* Find next highest priority task ready to run  */
        OS_ENTER_CRITICAL();
        if ((msg = OSTCBCur->OSTCBMsg) != (void *)0) {     /* See if we were given the message         */
            OSTCBCur->OSTCBMsg      = (void *)0;           /* Yes, clear message received              */
            OSTCBCur->OSTCBStat     = OS_STAT_RDY;
            OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;       /* No longer waiting for event              */
            OS_EXIT_CRITICAL();
            *err                    = OS_NO_ERR;
        } else if (OSTCBCur->OSTCBStat & OS_STAT_MBOX) {   /* If status is not OS_STAT_RDY, timed out  */
            OSEventTO(pevent);                             /* Make task ready                          */
            OS_EXIT_CRITICAL();
            msg                     = (void *)0;           /* Set message contents to NULL             */
            *err                    = OS_TIMEOUT;          /* Indicate that a timeout occured          */
        } else {
            msg                     = pevent->OSEventPtr;  /* Message received                         */
            pevent->OSEventPtr      = (void *)0;           /* Clear the mailbox                        */
            OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
            OS_EXIT_CRITICAL();
            *err                    = OS_NO_ERR;
        }
    }
    return (msg);                                          /* Return the message received (or NULL)    */
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                       POST MESSAGE TO A MAILBOX
*
* Description: This function sends a message to a mailbox
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
*
*              msg           is a pointer to the message to send.  You MUST NOT send a NULL pointer.  
*
* Returns    : OS_NO_ERR          The call was successful and the message was sent
*              OS_MBOX_FULL       If the mailbox already contains a message.  You can can only send one
*                                 message at a time and thus, the message MUST be consumed before you are
*                                 allowed to send another one.
*              OS_ERR_EVENT_TYPE  If you are attempting to post to a non mailbox.
*********************************************************************************************************
*/

INT8U OSMboxPost (OS_EVENT *pevent, void *msg)
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    if (pevent->OSEventGrp) {                         /* See if any task pending on mailbox            */
        OSEventTaskRdy(pevent, msg, OS_STAT_MBOX);    /* Ready highest priority task waiting on event  */
        //OS_EXIT_CRITICAL();
        OSSched();                                    /* Find highest priority task ready to run       */
        OS_EXIT_CRITICAL();//
        return (OS_NO_ERR);
    } else {
        if (pevent->OSEventPtr != (void *)0) {        /* Make sure mailbox doesn't already have a msg  */
            OS_EXIT_CRITICAL();
            return (OS_MBOX_FULL);
        } else {
            pevent->OSEventPtr = msg;                 /* Place message in mailbox                      */
            OS_EXIT_CRITICAL();
            return (OS_NO_ERR);
        }
    }
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                        QUERY A MESSAGE MAILBOX
*
* Description: This function obtains information about a message mailbox.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
*
*              pdata         is a pointer to a structure that will contain information about the message
*                            mailbox.
*
* Returns    : OS_NO_ERR          The call was successful and the message was sent
*              OS_ERR_EVENT_TYPE  If you are attempting to obtain data from a non mailbox.
*********************************************************************************************************
*/

INT8U OSMboxQuery (OS_EVENT *pevent, OS_MBOX_DATA *pdata)
{
    INT8U  i;
    INT8U *psrc;
    INT8U *pdest;
    
    
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    pdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &pdata->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    pdata->OSMsg = pevent->OSEventPtr;                     /* Get message from mailbox                 */
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
高清免费成人av| 91论坛在线播放| 97久久精品人人做人人爽| 欧美视频一区二区三区四区| 久久久久亚洲蜜桃| 亚洲成人手机在线| 9i在线看片成人免费| 欧美α欧美αv大片| 一区二区三区免费| 波多野结衣的一区二区三区| 日韩精品一区二区三区中文不卡| ㊣最新国产の精品bt伙计久久| 久久99这里只有精品| 欧美视频完全免费看| 激情综合色综合久久| 精品国产污网站| 欧美日韩国产免费一区二区 | 国产精品久久久一本精品| 日韩欧美一级特黄在线播放| 国产色91在线| 亚洲精品少妇30p| 亚洲制服丝袜av| 亚洲国产精品国自产拍av| 综合久久国产九一剧情麻豆| 国产老肥熟一区二区三区| 欧美伦理影视网| 亚洲成av人片www| 一本一道久久a久久精品综合蜜臀| 国产欧美一区二区在线观看| 国内不卡的二区三区中文字幕| 91精品国产欧美一区二区18| 午夜欧美视频在线观看| 欧美三级日韩在线| 丝袜美腿亚洲一区| 欧美精品xxxxbbbb| 视频一区在线视频| 日韩三级精品电影久久久| 琪琪久久久久日韩精品| 91麻豆精品91久久久久久清纯 | 一区二区三区四区激情 | 777午夜精品视频在线播放| 亚洲电影一级片| 4hu四虎永久在线影院成人| 欧美aa在线视频| 国产午夜精品美女毛片视频| 不卡的av中国片| 亚洲丝袜美腿综合| 欧美在线观看视频在线| 日日欢夜夜爽一区| 欧美mv和日韩mv的网站| 国产精品中文字幕日韩精品| 中文一区在线播放| caoporen国产精品视频| 亚洲大片一区二区三区| 欧美第一区第二区| 国产盗摄视频一区二区三区| 亚洲欧洲成人精品av97| 日韩欧美一区二区视频| 欧美日韩第一区日日骚| 久久久亚洲精华液精华液精华液| 2017欧美狠狠色| 亚洲免费观看高清完整版在线 | 日本欧美一区二区三区| 久久99热99| 欧美一区二区啪啪| 欧美肥妇free| 久久成人麻豆午夜电影| 亚洲欧美怡红院| 91精品国产综合久久福利软件| 国产精品一区二区在线播放| 亚洲免费毛片网站| 久久综合狠狠综合| 欧美在线色视频| 欧美一级久久久| 亚洲精品成人悠悠色影视| 成人在线视频一区| 国产精品视频九色porn| 成人免费视频播放| 久久久噜噜噜久噜久久综合| 国产成人在线观看| 国产精品久久久久久久久免费丝袜| 免费不卡在线视频| 日韩免费视频线观看| 国产精品夜夜嗨| 国产精品蜜臀在线观看| 91国产福利在线| 三级亚洲高清视频| 亚洲精品一区二区三区四区高清| 韩国精品在线观看| 国产精品电影一区二区| 91成人免费在线| 亚洲成a人在线观看| 欧美一级日韩不卡播放免费| 国内精品免费**视频| 欧美国产一区视频在线观看| 成人激情开心网| 亚洲国产精品一区二区尤物区| 欧美日韩高清一区二区不卡| 久久狠狠亚洲综合| 国产精品乱码人人做人人爱| 在线观看视频91| 2023国产精品视频| 色天使色偷偷av一区二区| 粉嫩av一区二区三区在线播放 | 在线观看免费一区| 处破女av一区二区| 国产精品18久久久久久久久| 国产麻豆精品久久一二三| 午夜影院久久久| 精品毛片乱码1区2区3区| 久久激情综合网| 色成人在线视频| 91一区在线观看| 韩国v欧美v亚洲v日本v| 亚洲欧美另类在线| 亚洲精品国产a| 国产高清无密码一区二区三区| 粉嫩高潮美女一区二区三区 | 亚洲精品国产a| 亚洲欧美日韩小说| 亚洲精品第1页| 亚洲午夜精品久久久久久久久| 一卡二卡欧美日韩| 亚洲成人先锋电影| 日本不卡视频在线观看| 蜜臀久久久久久久| 激情国产一区二区| 国产精品18久久久久| 成人午夜在线播放| 91久久精品一区二区三| 欧美中文字幕一二三区视频| 91精品国产综合久久精品 | 精品亚洲免费视频| 国产精品一卡二卡| 色综合夜色一区| 欧美一区二区三区成人| 欧美xxxx在线观看| 国产精品人成在线观看免费| 亚洲欧美日韩国产中文在线| 亚洲成人黄色小说| 国产一区二区视频在线播放| 本田岬高潮一区二区三区| 日本精品一区二区三区四区的功能| 欧美三区免费完整视频在线观看| 日韩一级大片在线| eeuss鲁一区二区三区| 日韩精品一区第一页| 亚洲第一狼人社区| 亚洲电影激情视频网站| 亚洲一区二区五区| 亚洲福利一二三区| 亚洲成人av一区二区三区| 亚洲尤物在线视频观看| 亚洲免费高清视频在线| 亚洲精品视频一区二区| 一区二区三区国产精品| 偷拍亚洲欧洲综合| 丝袜美腿亚洲色图| 捆绑调教一区二区三区| 国产在线播精品第三| 精品一区二区三区欧美| 国内精品国产成人国产三级粉色 | 久久97超碰国产精品超碰| 久久er99热精品一区二区| 国产米奇在线777精品观看| 国产成人av影院| 成人av电影在线网| 色哟哟一区二区三区| 欧美精选一区二区| 精品国内片67194| 国产精品欧美极品| 亚洲欧美国产高清| 婷婷国产在线综合| 国产一区二区三区免费看| 99久久99久久久精品齐齐| 日本乱人伦aⅴ精品| 日韩午夜中文字幕| 国产精品久久久久一区| 亚洲成人免费av| 成人中文字幕在线| 欧美高清视频不卡网| 91国偷自产一区二区使用方法| 91精品国产福利在线观看| 亚洲午夜视频在线观看| 色婷婷综合久久久中文字幕| 欧美激情艳妇裸体舞| 国产.欧美.日韩| 精品国产91乱码一区二区三区| 日韩国产欧美在线播放| 欧美久久高跟鞋激| 日本视频在线一区| 91精品国产一区二区三区香蕉| 五月天激情小说综合| 欧美精三区欧美精三区| 午夜久久久久久电影| 7777精品久久久大香线蕉| 午夜精品久久久久久久久 | 99久久99久久精品国产片果冻| 久久久电影一区二区三区| 久久aⅴ国产欧美74aaa|