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

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

?? os_mbox.c

?? ucos很好的學習代碼
?? 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();                                    /* 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       */
        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一区二区三区免费野_久草精品视频
91精品国产综合久久久久久| 久久先锋影音av| 精彩视频一区二区| 国产精品久久久99| 日韩欧美国产一区在线观看| av一区二区三区黑人| 免费人成网站在线观看欧美高清| 中文欧美字幕免费| 精品美女被调教视频大全网站| 日本大香伊一区二区三区| 国产精品一区二区在线看| 日韩中文字幕不卡| 亚洲精品国产高清久久伦理二区| 久久久久久一二三区| 91精品国产综合久久国产大片| 91啪在线观看| 成人av影视在线观看| 激情文学综合网| 香蕉久久一区二区不卡无毒影院| 国产精品电影院| 日本一区二区免费在线观看视频| 欧美tk—视频vk| 欧美蜜桃一区二区三区| 色婷婷亚洲综合| 色偷偷成人一区二区三区91| 成人av影视在线观看| 国产盗摄一区二区| 国产乱子轮精品视频| 精品亚洲国内自在自线福利| 奇米888四色在线精品| 国产成人在线视频免费播放| 午夜欧美视频在线观看| 亚洲一区免费观看| 一区二区三区在线免费| 亚洲另类春色国产| 一区二区三区国产豹纹内裤在线| 亚洲久草在线视频| 亚洲三级在线观看| 亚洲欧美乱综合| 亚洲精品精品亚洲| 亚洲电影第三页| 日欧美一区二区| 美女www一区二区| 麻豆精品在线看| 韩国三级电影一区二区| 国产一级精品在线| 国产91丝袜在线18| caoporm超碰国产精品| 色网综合在线观看| 欧美日韩日日夜夜| 日韩欧美一区二区免费| 久久久亚洲午夜电影| 中文字幕 久热精品 视频在线| 中文一区在线播放| 亚洲视频你懂的| 亚洲国产精品人人做人人爽| 日韩福利电影在线观看| 久久国产人妖系列| 国产.欧美.日韩| 91免费看视频| 欧美日韩久久久| 欧美成人官网二区| 国产精品网站在线| 亚洲一区二区免费视频| 欧美aⅴ一区二区三区视频| 九九九精品视频| 成人国产电影网| 欧美色欧美亚洲另类二区| 日韩精品中文字幕在线一区| 欧美国产激情二区三区| 一区二区三区欧美日韩| 免费观看在线色综合| 国产白丝精品91爽爽久久| 色综合久久中文字幕综合网| 欧美日韩国产一二三| 久久久99精品久久| 亚洲综合一区二区精品导航| 麻豆视频观看网址久久| 成人高清在线视频| 在线综合视频播放| 国产精品不卡在线| 蜜臀久久99精品久久久久宅男| 国产成人在线视频网址| 欧美日韩国产精品自在自线| 亚洲精品在线三区| 亚洲精品国久久99热| 国产在线日韩欧美| 欧美影院精品一区| 日本一区二区免费在线观看视频| 亚洲成人动漫在线观看| 国产成人精品免费网站| 欧美精品在线一区二区三区| 亚洲色图欧洲色图婷婷| 久久丁香综合五月国产三级网站| 一本久久精品一区二区| 精品国免费一区二区三区| 亚洲精品高清在线观看| 国产黑丝在线一区二区三区| 精品视频在线免费| 亚洲欧洲国产专区| 激情五月激情综合网| 欧美日本国产视频| 亚洲欧美激情插| 国产伦精品一区二区三区在线观看| 欧美日韩国产小视频在线观看| 国产精品久久久久久久久果冻传媒| 蜜桃视频免费观看一区| 91黄色免费网站| 国产精品嫩草影院av蜜臀| 激情伊人五月天久久综合| 欧美精品第1页| 一级精品视频在线观看宜春院| 国产成人精品www牛牛影视| 欧美伦理电影网| 亚洲一区在线电影| 91免费看`日韩一区二区| 欧美激情在线免费观看| 精品写真视频在线观看| 欧美一级片在线| 性做久久久久久久久| 欧美系列在线观看| 亚洲三级视频在线观看| 国产91丝袜在线播放九色| 精品国产一区a| 麻豆91精品91久久久的内涵| 91精品国产综合久久精品图片 | 成人国产一区二区三区精品| 久久毛片高清国产| 精品一区二区三区久久| 日韩免费电影一区| 日本一不卡视频| 91精品午夜视频| 麻豆精品久久精品色综合| 91精品国产免费久久综合| 水野朝阳av一区二区三区| 欧美日韩中字一区| 午夜精品123| 91麻豆精品国产91久久久久| 婷婷中文字幕综合| 欧美丰满嫩嫩电影| 日韩电影一区二区三区四区| 5858s免费视频成人| 午夜激情一区二区三区| 欧美精品vⅰdeose4hd| 日韩av一区二区三区| 日韩精品一区二| 国产精品88888| 欧美激情中文不卡| 91视视频在线观看入口直接观看www | 免费在线观看视频一区| 91精品国产欧美一区二区| 麻豆精品在线看| 日本一区二区免费在线观看视频| 欧美日韩精品一区二区三区四区| 亚洲国产视频直播| 欧美一区二区三区在线电影| 九九国产精品视频| 国产欧美日韩另类一区| 色综合一区二区三区| 粉嫩aⅴ一区二区三区四区 | 欧美日韩激情一区二区| 久久av资源网| 国产精品系列在线| 欧美色爱综合网| 国产在线精品免费av| 国产精品免费av| 欧美在线免费观看亚洲| 久久成人综合网| 成人欧美一区二区三区黑人麻豆 | 欧美成人一区二区三区在线观看| 国产一区二区在线视频| 亚洲欧洲精品成人久久奇米网| 欧美三级乱人伦电影| 久久国产婷婷国产香蕉| 亚洲欧美日韩国产成人精品影院 | 精品国产自在久精品国产| 不卡的电影网站| 亚洲成av人片在线| 久久精品亚洲一区二区三区浴池| 91老司机福利 在线| 日本免费在线视频不卡一不卡二| 国产午夜三级一区二区三| 欧美伊人精品成人久久综合97 | 久久精品人人做人人爽人人| 91蜜桃视频在线| 久久电影网站中文字幕 | 免费日韩伦理电影| 亚洲天堂精品在线观看| 日韩欧美一级二级三级| 99久久久精品免费观看国产蜜| 蜜臀精品久久久久久蜜臀| 国产精品久久久久久久久图文区| 欧美高清hd18日本| 99re热这里只有精品视频| 久久99国产乱子伦精品免费| 一区二区在线观看免费| 国产午夜精品理论片a级大结局| 欧美主播一区二区三区美女| 国产aⅴ精品一区二区三区色成熟| 丝袜亚洲精品中文字幕一区|