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

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

?? os_sem.c

?? keil下單片機C8051F020的源程序
?? C
字號:
/*
*********************************************************************************************************
*                                                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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕欧美日韩一区| 亚洲午夜精品在线| 丁香网亚洲国际| 国产欧美精品一区| 欧美日韩国产小视频在线观看| 亚洲一二三区视频在线观看| 精品午夜久久福利影院| 91精品国产全国免费观看| 国产精品中文欧美| av资源站一区| 一区二区三区资源| 久久综合九色综合欧美98| 欧美色国产精品| 国产91精品一区二区麻豆亚洲| 亚洲成av人片在线| 亚洲精品国产a| 国产欧美一区二区精品忘忧草| 51午夜精品国产| 亚洲欧美日韩国产成人精品影院 | 丁香婷婷综合激情五月色| 日韩欧美一区二区三区在线| 日韩综合小视频| 91精品国产色综合久久| 久久机这里只有精品| 久久理论电影网| 成人av手机在线观看| 久久这里只有精品首页| 亚洲国产日产av| www国产亚洲精品久久麻豆| 岛国av在线一区| 最好看的中文字幕久久| 日韩午夜在线影院| 91猫先生在线| 国产一区二区三区久久久| 国产精品国产三级国产aⅴ入口| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 秋霞午夜av一区二区三区| 日韩情涩欧美日韩视频| 国产91精品一区二区| 亚洲无线码一区二区三区| 91论坛在线播放| 亚洲特级片在线| 国模冰冰炮一区二区| 久久众筹精品私拍模特| 91蜜桃网址入口| 国产在线精品免费| 日本道在线观看一区二区| 91精品国产综合久久国产大片| 处破女av一区二区| 国产不卡在线视频| 成人免费高清在线观看| 波多野结衣91| 在线亚洲精品福利网址导航| 91电影在线观看| 欧美精品一级二级| 91精品久久久久久久久99蜜臂| 欧美日韩精品电影| 8v天堂国产在线一区二区| 日韩一区二区三区av| 欧美大度的电影原声| 久久久亚洲午夜电影| 国产精品久久久久久久久晋中| 亚洲欧美一区二区在线观看| 一区二区三区在线视频免费观看| 亚洲午夜免费电影| 久久精品国产精品亚洲综合| 国产精品小仙女| 成人h动漫精品一区二区| 97se狠狠狠综合亚洲狠狠| 色婷婷综合久色| 日韩一区二区三区视频| 国产亚洲一区二区三区在线观看| 中文字幕第一区第二区| 亚洲精品欧美专区| 老司机午夜精品99久久| 成人精品电影在线观看| 在线精品国精品国产尤物884a| 日韩午夜在线影院| 国产精品欧美极品| 午夜精品视频在线观看| 国产一区二区在线看| 92精品国产成人观看免费| 欧美日本韩国一区二区三区视频| 精品粉嫩aⅴ一区二区三区四区| 国产精品私人影院| 天天综合网 天天综合色| 国产成a人无v码亚洲福利| 欧美日韩三级在线| 国产欧美精品一区| 视频一区欧美日韩| 成人国产电影网| 日韩欧美在线网站| 亚洲欧美一区二区三区国产精品| 奇米一区二区三区| 成人性生交大片免费看视频在线| 欧美性猛片aaaaaaa做受| 欧美精品一区二区三区高清aⅴ| 亚洲免费高清视频在线| 精油按摩中文字幕久久| 91福利视频网站| 中文字幕免费在线观看视频一区| 亚洲成人一区在线| 成人免费观看视频| 精品噜噜噜噜久久久久久久久试看| 中文字幕一区二区三区在线观看| 捆绑调教一区二区三区| 色国产精品一区在线观看| 国产欧美一区二区在线观看| 奇米影视一区二区三区小说| 欧美亚一区二区| 国产精品毛片a∨一区二区三区| 免费一级片91| 欧美亚洲国产bt| 亚洲人成亚洲人成在线观看图片 | 亚洲自拍偷拍av| 国产成人综合在线观看| 91精品国产色综合久久ai换脸 | 久久久www成人免费无遮挡大片| 日韩中文字幕麻豆| 91久久国产综合久久| 国产精品福利av| 国产大陆亚洲精品国产| 精品日韩在线一区| 日本成人在线不卡视频| 欧美中文字幕一区二区三区亚洲| 国产精品每日更新| 成人综合在线视频| 国产亚洲欧美日韩在线一区| 久久国产精品无码网站| 欧美久久久一区| 天天影视涩香欲综合网| 欧美日韩一区在线观看| 亚洲成人免费av| 欧美三级视频在线观看| 亚洲成av人片在线观看无码| 欧美日韩精品免费| 亚洲18色成人| 在线不卡一区二区| 午夜av区久久| 日韩一区国产二区欧美三区| 天堂久久一区二区三区| 欧美伦理视频网站| 日本在线播放一区二区三区| 欧美一区二区三区视频在线| 婷婷中文字幕综合| 欧美一区二区三区免费视频| 久久丁香综合五月国产三级网站| 日韩欧美成人激情| 国产美女精品在线| 日本一区二区在线不卡| av在线免费不卡| 亚洲午夜电影网| 欧美卡1卡2卡| 久久99深爱久久99精品| 久久免费电影网| 99久久综合国产精品| 亚洲免费资源在线播放| 欧美三级日韩三级国产三级| 男女性色大片免费观看一区二区 | 大白屁股一区二区视频| 亚洲三级理论片| 欧美精品 国产精品| 免费在线看成人av| 国产亚洲一本大道中文在线| 91色在线porny| 日韩成人av影视| 欧美xxxxxxxxx| 成人免费高清视频| 亚洲国产精品久久久久婷婷884| 666欧美在线视频| 丁香婷婷综合网| 一区二区三区在线观看国产| 制服丝袜在线91| 国产成人在线视频免费播放| 亚洲欧美日韩综合aⅴ视频| 欧美日韩亚洲高清一区二区| 久久精品国产999大香线蕉| 国产日本欧美一区二区| 在线亚洲免费视频| 狠狠色丁香婷婷综合| 亚洲素人一区二区| 欧美一区二区三区系列电影| 不卡视频在线看| 日韩和欧美的一区| 国产精品水嫩水嫩| 91精品啪在线观看国产60岁| 菠萝蜜视频在线观看一区| 视频一区免费在线观看| 国产精品久久久久久久久免费樱桃 | 成人黄色电影在线| 五月婷婷欧美视频| 亚洲国产电影在线观看| 欧美美女一区二区| 99精品偷自拍| 国产呦精品一区二区三区网站| 一区二区三区在线视频免费观看| 精品国产91洋老外米糕| 色呦呦一区二区三区| 国产在线观看一区二区| 亚洲bt欧美bt精品|