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

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

?? os_sem.c

?? C51單片機上的嵌入式操作系統,具有任務調度,文件服務,等功能
?? 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
*********************************************************************************************************
*/
#if OS_Sem_Accept_EN
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                        */
}
#endif

/*$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
*********************************************************************************************************
*/
#if OS_Sem_Create_EN
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);
}
#endif

/*$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
*********************************************************************************************************
*/
#if OS_Sem_Pend_EN
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;
        }
    }
}
#endif
/*$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
*********************************************************************************************************
*/
#if OS_Sem_Post_EN
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);
        }
    }
}
#endif
/*
*********************************************************************************************************
*                                          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
*
*              dataptr         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.
*********************************************************************************************************
*/
#if   OS_Sem_Query_EN
INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *dataptr)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);
    }
    dataptr->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &dataptr->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    dataptr->OSCnt      = pevent->OSEventCnt;                /* Get semaphore count                      */
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
#endif
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91性感美女视频| 777亚洲妇女| 日韩高清国产一区在线| 久久久久国产一区二区三区四区| 国产欧美日韩精品在线| 精品一区二区三区在线观看| 国产午夜精品理论片a级大结局| 在线欧美日韩精品| 国产在线精品一区二区不卡了 | 337p日本欧洲亚洲大胆精品| 色88888久久久久久影院野外| 激情图区综合网| 亚洲午夜久久久久久久久久久| 久久精品无码一区二区三区| 欧美一级久久久| 91免费版pro下载短视频| 精品一区二区免费看| 天天操天天干天天综合网| 欧美精品一区二区三区久久久| 在线观看中文字幕不卡| 成人高清免费在线播放| 精品一区二区三区在线观看| 蜜桃91丨九色丨蝌蚪91桃色| 亚洲电影一区二区三区| 伊人性伊人情综合网| 亚洲欧洲性图库| 国产日韩精品一区二区三区在线| 日韩欧美国产小视频| 91精品国产综合久久国产大片| 日本乱人伦一区| 91黄色小视频| 色婷婷精品久久二区二区蜜臂av | 色综合久久综合网97色综合 | 久草中文综合在线| 男男视频亚洲欧美| 日本不卡123| 日日摸夜夜添夜夜添国产精品 | 国产精品网站一区| 日韩二区三区在线观看| 国产精品天干天干在线综合| 久久久久久毛片| 久久你懂得1024| 国产欧美一区视频| 日本一区二区免费在线| 亚洲国产成人私人影院tom| 久久精品欧美日韩精品| 国产精品网站在线播放| 国产精品成人一区二区艾草| 亚洲图片激情小说| 玉足女爽爽91| 亚洲国产一区二区视频| 肉色丝袜一区二区| 激情都市一区二区| 国产成人激情av| 色屁屁一区二区| 欧美精品色综合| 欧美mv日韩mv| 亚洲国产精品ⅴa在线观看| 日韩美女精品在线| 亚洲一区二区在线免费观看视频| 亚洲一区二区av电影| 美女尤物国产一区| 国产传媒一区在线| 色综合天天综合狠狠| 欧美高清视频在线高清观看mv色露露十八 | 日本欧美一区二区三区| 老司机精品视频导航| 国产福利一区在线| 91久久国产综合久久| 欧美人与z0zoxxxx视频| 精品福利av导航| 亚洲欧美日韩中文播放| 日本不卡视频在线观看| 国产在线播放一区| 色女孩综合影院| 欧美大尺度电影在线| 欧美激情综合网| 亚洲成人精品在线观看| 国产一区二区电影| 日本韩国精品一区二区在线观看| 91麻豆精品久久久久蜜臀| 久久久久久**毛片大全| 亚洲高清免费在线| 国产精品亚洲一区二区三区妖精| 91福利精品第一导航| 精品国产乱码久久久久久蜜臀| 中文字幕一区二区三| 免费三级欧美电影| 色哟哟国产精品免费观看| 日韩精品一区二区三区视频在线观看| 国产精品情趣视频| 麻豆国产欧美一区二区三区| 91小视频在线观看| 久久―日本道色综合久久| 亚洲国产成人av网| 成人性生交大片免费| 日韩一区二区三区观看| 亚洲免费av高清| 国产精品一区二区在线观看不卡 | 久久网站热最新地址| 一区二区欧美在线观看| 国产成人午夜视频| 56国语精品自产拍在线观看| 亚洲三级视频在线观看| 国产中文字幕精品| 欧美日韩mp4| 亚洲免费av高清| 成人精品国产福利| 精品欧美一区二区久久| 污片在线观看一区二区| 在线观看av一区| 国产精品美女久久久久久久| 国产原创一区二区三区| 欧美不卡视频一区| 日韩国产精品大片| 欧美日韩在线播放一区| 亚洲理论在线观看| av电影天堂一区二区在线观看| 久久久一区二区三区捆绑**| 久久国产精品一区二区| 欧美一区二区在线免费播放| 亚洲永久免费视频| 在线观看av不卡| 亚洲精品写真福利| 日本精品视频一区二区| 亚洲男女一区二区三区| www.成人网.com| 国产精品三级在线观看| 成人丝袜18视频在线观看| 久久这里只有精品首页| 狠狠狠色丁香婷婷综合久久五月| 51精品视频一区二区三区| 亚洲国产精品影院| 欧美视频在线一区二区三区 | 91无套直看片红桃| 国产精品国产自产拍高清av| 成人污视频在线观看| 国产91富婆露脸刺激对白| 欧美一区二区在线视频| 蜜臀久久99精品久久久久宅男| 欧美日韩的一区二区| 午夜精品成人在线视频| 欧美一区二区在线免费观看| 轻轻草成人在线| 精品国产乱码久久久久久浪潮| 国产一区二区三区最好精华液| 久久人人爽人人爽| 欧美日韩一二区| 日av在线不卡| 精品国产sm最大网站免费看| 久久99精品国产麻豆婷婷| 久久婷婷色综合| k8久久久一区二区三区| 亚洲人精品一区| 欧美日韩视频在线观看一区二区三区| 亚洲成人动漫在线观看| 欧美成人a∨高清免费观看| 国产 日韩 欧美大片| 亚洲欧美一区二区三区国产精品| 欧美中文字幕一区二区三区亚洲 | 成人18视频日本| 一区二区三区av电影| 这里只有精品视频在线观看| 国产在线观看免费一区| 国产精品久久久久9999吃药| 欧美午夜片在线观看| 激情小说欧美图片| 国产精品视频第一区| 欧美日韩在线播放三区四区| 狠狠v欧美v日韩v亚洲ⅴ| 国产精品久久久久久久裸模 | 中文字幕一区二区三| 91超碰这里只有精品国产| 国产在线精品视频| 一区二区三区视频在线看| 日韩天堂在线观看| 99视频精品免费视频| 全国精品久久少妇| 国产精品久久久久久久蜜臀| 欧美一区二区视频在线观看2020| 国产精品一二二区| 亚洲一区二区三区中文字幕| 久久综合中文字幕| 欧美亚洲另类激情小说| 国产成人免费视频精品含羞草妖精 | 欧美日韩亚洲综合一区| 国产精品99久久久| 午夜视频一区在线观看| 国产精品免费免费| 精品人在线二区三区| 欧美日韩一区二区在线观看| 国产69精品久久久久毛片| 欧美a级理论片| 亚洲影院免费观看| 国产精品欧美一区二区三区| 日韩小视频在线观看专区| 欧洲在线/亚洲| 99久久国产综合精品女不卡| 久久99久久精品| 首页综合国产亚洲丝袜|