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

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

?? os_sem.c

?? c8051f040單片機(jī)上的UCOS 移植代碼
?? C
字號(hào):
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
*                                           All Rights Reserved
*
*                                                  V2.00
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

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

#if OS_SEM_EN
/*
*********************************************************************************************************
*                                           ACCEPT SEMAPHORE
*
* Description: This function checks the semaphore to see if a resource is available or, if an event
*              occurred.  Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the
*              resource is not available or the event did not occur.
*
* Arguments  : pevent     is a pointer to the event control block
*
* Returns    : >  0       if the resource is available or the event did not occur the semaphore is
*                         decremented to obtain the resource.
*              == 0       if the resource is not available or the event did not occur or,
*                         you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

INT16U OSSemAccept (OS_EVENT *pevent) reentrant
{
    INT16U cnt;


    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        return (0);
    }
    cnt = pevent->OSEventCnt;
    if (cnt > 0) {                                    /* See if resource is available                  */
        pevent->OSEventCnt--;                         /* Yes, decrement semaphore and notify caller    */
    }
    OS_EXIT_CRITICAL();
    return (cnt);                                     /* Return semaphore count                        */
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                           CREATE A SEMAPHORE
*
* Description: This function creates a semaphore.
*
* Arguments  : cnt           is the initial value for the semaphore.  If the value is 0, no resource is
*                            available (or no event has occurred).  You initialize the semaphore to a 
*                            non-zero value to specify how many resources are available (e.g. if you have
*                            10 resources, you would initialize the semaphore to 10).
*
* Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                            created semaphore
*              == (void *)0  if no event control blocks were available
*********************************************************************************************************
*/

OS_EVENT *OSSemCreate (INT16U cnt) reentrant
{
    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) {                         /* Get an event control block               */
        pevent->OSEventType = OS_EVENT_TYPE_SEM;
        pevent->OSEventCnt  = cnt;                         /* Set semaphore value                      */
        OSEventWaitListInit(pevent);
    }
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                           PEND ON SEMAPHORE
*
* Description: This function waits for a semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore.
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for the resource up to the amount of time specified by this argument.  
*                            If you specify 0, however, your task will wait forever at the specified 
*                            semaphore or, until the resource becomes available (or the event occurs).
*
*              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 owns the resource 
*                                               or, the event you are waiting for occurred.
*                            OS_TIMEOUT         The semaphore was not received within the specified 
*                                               timeout.
*                            OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR    If you called this function from an ISR and the result
*                                               would lead to a suspension.
*
* Returns    : none
*********************************************************************************************************
*/

void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err) reentrant
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        *err = OS_ERR_EVENT_TYPE;
    }
    if (pevent->OSEventCnt > 0) {                     /* If sem. is positive, resource available ...   */
        pevent->OSEventCnt--;                         /* ... decrement semaphore only if positive.     */
        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 {                                          /* Otherwise, must wait until event occurs       */
        OSTCBCur->OSTCBStat    |= OS_STAT_SEM;        /* Resource not available, pend on semaphore     */
        OSTCBCur->OSTCBDly      = timeout;            /* Store pend timeout in TCB                     */
        OSEventTaskWait(pevent);                      /* Suspend task until event or timeout occurs    */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find next highest priority task ready         */
        OS_ENTER_CRITICAL();
        if (OSTCBCur->OSTCBStat & OS_STAT_SEM) {      /* Must have timed out if still waiting for event*/
            OSEventTO(pevent);
            OS_EXIT_CRITICAL();
            *err = OS_TIMEOUT;                        /* Indicate that didn't get event within TO      */
        } else {
            OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
            OS_EXIT_CRITICAL();
            *err = OS_NO_ERR;
        }
    }
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                         POST TO A SEMAPHORE
*
* Description: This function signals a semaphore
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore.
*
* Returns    : OS_NO_ERR          The call was successful and the semaphore was signaled.
*              OS_SEM_OVF         If the semaphore count exceeded its limit.  In other words, you have 
*                                 signalled the semaphore more often than you waited on it with either
*                                 OSSemAccept() or OSSemPend().
*              OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

INT8U OSSemPost (OS_EVENT *pevent) reentrant
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    if (pevent->OSEventGrp) {                              /* See if any task waiting for semaphore    */
        OSEventTaskRdy(pevent, (void *)0, OS_STAT_SEM);    /* Ready highest prio task waiting on event */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find highest priority task ready to run       */
        return (OS_NO_ERR);
    } else {
        if (pevent->OSEventCnt < 65535) {             /* Make sure semaphore will not overflow         */
            pevent->OSEventCnt++;                     /* Increment semaphore count to register event   */
            OS_EXIT_CRITICAL();
            return (OS_NO_ERR);
        } else {                                      /* Semaphore value has reached its maximum       */
            OS_EXIT_CRITICAL();
            return (OS_SEM_OVF);
        }
    }
}
/*
*********************************************************************************************************
*                                          QUERY A SEMAPHORE
*
* Description: This function obtains information about a semaphore
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore
*
*              pdata         is a pointer to a structure that will contain information about the 
*                            semaphore.
*
* 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 semaphore.
*********************************************************************************************************
*/

INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *ppdata) reentrant
{
    INT8U  i;
    INT8U *psrc;
    INT8U *pdest;
    
    
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    ppdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &ppdata->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    ppdata->OSCnt      = pevent->OSEventCnt;                /* Get semaphore count                      */
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
#endif

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区精品| 在线不卡一区二区| 亚洲成人综合网站| 国产精品免费视频一区| 欧美一区二区精品久久911| 丁香婷婷综合激情五月色| 丝袜亚洲另类欧美综合| 亚洲免费三区一区二区| 国产日韩欧美综合在线| 日韩一区二区三区四区五区六区 | 福利电影一区二区| 亚洲成av人片| 中文字幕一区二区三区在线播放| 精品国产污网站| 欧美日韩国产综合一区二区三区 | 中文字幕不卡的av| 日韩欧美精品在线| 欧美日韩精品一区二区三区四区| 99精品欧美一区二区三区小说 | 中文字幕精品一区| 精品精品国产高清a毛片牛牛 | 精品久久久久久久一区二区蜜臀| 欧美无砖专区一中文字| 色婷婷一区二区三区四区| 不卡的电视剧免费网站有什么| 激情国产一区二区| 久久疯狂做爰流白浆xx| 日韩在线一二三区| 丝袜亚洲精品中文字幕一区| 亚洲午夜视频在线| 一区二区三区四区亚洲| 亚洲六月丁香色婷婷综合久久| 亚洲国产岛国毛片在线| 国产偷国产偷精品高清尤物 | 午夜久久久久久久久久一区二区| 亚洲手机成人高清视频| 国产精品超碰97尤物18| 亚洲国产精品传媒在线观看| 国产精品丝袜久久久久久app| 久久综合九色欧美综合狠狠| 亚洲精品一区二区三区精华液 | 欧美日韩免费观看一区三区| 在线欧美日韩精品| 欧美日韩一区二区三区在线| 欧美在线免费观看视频| 欧美日韩一区二区三区四区五区| 欧美日韩在线直播| 91麻豆精品国产91久久久资源速度 | 久久成人综合网| 九九精品一区二区| 国产福利一区在线观看| 国产精品 日产精品 欧美精品| 国产91丝袜在线18| av在线综合网| 欧美日韩一区久久| 日韩欧美国产一区在线观看| 久久久亚洲精品石原莉奈| 国产欧美精品一区aⅴ影院| 综合在线观看色| 午夜精品久久久久久久久| 麻豆国产精品视频| 国产伦精一区二区三区| 91麻豆国产福利在线观看| 欧美日韩美少妇| 精品久久久久久久久久久久包黑料 | 国产呦萝稀缺另类资源| 成人精品视频.| 日本精品一级二级| 日韩视频一区二区三区| 国产欧美日韩在线| 亚洲综合在线电影| 精品一区二区久久久| 不卡的电影网站| 在线不卡免费欧美| 国产精品第五页| 日韩va亚洲va欧美va久久| 国产盗摄视频一区二区三区| 色激情天天射综合网| 日韩精品一区二区三区在线播放| 欧美高清在线视频| 丝瓜av网站精品一区二区| 国产成人精品一区二区三区四区 | 久久影院午夜论| 亚洲女子a中天字幕| 奇米在线7777在线精品| 99久久99久久免费精品蜜臀| 欧美一级免费观看| 亚洲日本免费电影| 精品在线一区二区三区| 91麻豆免费在线观看| 精品99一区二区| 亚洲高清免费观看| 成人avav影音| 欧美精品一区二区三区四区| 亚洲午夜精品一区二区三区他趣| 国产中文字幕精品| 欧美日韩国产天堂| 亚洲欧洲日本在线| 国内精品视频一区二区三区八戒| 欧美手机在线视频| 亚洲图片激情小说| 国产精品99久久久久久有的能看| 欧美日韩精品欧美日韩精品| 国产精品灌醉下药二区| 国产一区二区三区精品欧美日韩一区二区三区| 97久久精品人人做人人爽50路| 欧美电视剧在线观看完整版| 亚洲成人免费在线观看| 91丨九色丨黑人外教| 久久久99精品免费观看不卡| 午夜精品福利在线| 91蜜桃视频在线| 国产日韩欧美综合在线| 经典三级在线一区| 337p亚洲精品色噜噜| 亚洲成av人片一区二区| 欧美综合一区二区三区| 亚洲女厕所小便bbb| 成人精品小蝌蚪| 国产精品色噜噜| 粉嫩蜜臀av国产精品网站| 26uuu亚洲综合色欧美| 另类欧美日韩国产在线| 日韩三级电影网址| 日本一不卡视频| 538在线一区二区精品国产| 亚洲一区二区三区四区五区中文 | 老司机一区二区| 欧美一区二区网站| 日韩va欧美va亚洲va久久| 欧美乱妇15p| 偷拍亚洲欧洲综合| 欧美精品亚洲一区二区在线播放| 一区二区三区中文字幕精品精品| 色婷婷综合久久久久中文 | 亚洲综合成人在线| 91精彩视频在线观看| 亚洲专区一二三| 欧美午夜精品久久久久久孕妇| 亚洲黄色性网站| 欧美视频一区二区| 日韩国产精品久久| 欧美成人一区二区三区片免费| 久草在线在线精品观看| 久久久久久麻豆| 成人综合在线观看| 亚洲欧美精品午睡沙发| 欧美日韩国产不卡| 免费久久99精品国产| 久久久天堂av| 99精品黄色片免费大全| 亚洲午夜三级在线| 欧美成人性福生活免费看| 国产成人免费视频一区| 专区另类欧美日韩| 欧美精品自拍偷拍| 韩国av一区二区三区在线观看| 欧美国产精品一区二区| 99re66热这里只有精品3直播| 亚洲亚洲精品在线观看| 精品国产一区二区三区久久久蜜月| 国产一区二区伦理| 亚洲免费资源在线播放| 欧美一区二区三区日韩视频| 国产精品一区三区| 亚洲情趣在线观看| 日韩一区二区在线观看视频| 丁香婷婷综合色啪| 日日摸夜夜添夜夜添国产精品 | 日本不卡一区二区三区高清视频| 欧美tickling挠脚心丨vk| 成人毛片老司机大片| 亚洲成人av资源| 国产清纯白嫩初高生在线观看91 | 中文字幕在线一区免费| 欧美久久婷婷综合色| 国产福利91精品| 亚洲一区二区三区小说| 久久久国产精华| 欧美日韩午夜影院| 国产精品亚洲一区二区三区妖精| 一区二区三区四区国产精品| 精品国产自在久精品国产| 色菇凉天天综合网| 国产一区二区主播在线| 亚洲综合自拍偷拍| 久久久久久久免费视频了| 欧美三区在线视频| 国产成人综合自拍| 免费av网站大全久久| 有坂深雪av一区二区精品| 久久精品一区二区三区不卡| 欧美日本乱大交xxxxx| 成人动漫一区二区三区| 麻豆传媒一区二区三区| 亚洲精品成人在线| 中文字幕va一区二区三区| 精品国产乱码91久久久久久网站| 欧美亚洲高清一区二区三区不卡| 国产91在线|亚洲|