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

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

?? os_sem.c

?? μC/OS-Ⅱ實時嵌入式操作系統源代碼
?? 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)
{
    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)
{
    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)
{
    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)
{
    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 *pdata)
{
    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);
    }
    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->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色.com| 午夜国产精品影院在线观看| 亚洲美女视频在线观看| 奇米色一区二区三区四区| 粉嫩嫩av羞羞动漫久久久| 欧美久久久久久久久久| 国产精品每日更新在线播放网址| 一级特黄大欧美久久久| 国产91在线|亚洲| 日韩一区二区三区av| 亚洲同性同志一二三专区| 国产曰批免费观看久久久| 欧美日韩在线观看一区二区 | 国产欧美日韩久久| 亚洲mv大片欧洲mv大片精品| 成人性生交大片免费看在线播放| 日韩精品一区二区三区在线播放| 亚洲一区自拍偷拍| 99久久精品免费看国产| 国产日韩欧美在线一区| 麻豆成人av在线| 欧美精品777| 亚洲二区在线观看| 色综合久久久网| 成人免费在线视频| 成人午夜av影视| 欧美国产精品一区二区| 国产乱人伦偷精品视频免下载| 欧美一激情一区二区三区| 香蕉成人啪国产精品视频综合网| 日本高清免费不卡视频| 国产精品高潮呻吟| 日韩精品专区在线影院重磅| 亚洲妇女屁股眼交7| 91首页免费视频| 亚洲婷婷在线视频| 色美美综合视频| 一区二区三区在线免费| 91猫先生在线| 亚洲国产成人porn| 欧美日本国产一区| 欧美a级一区二区| 精品黑人一区二区三区久久 | 综合色中文字幕| av激情亚洲男人天堂| 国产精品动漫网站| 在线一区二区视频| 香蕉久久夜色精品国产使用方法| 欧美一区二区播放| 国产精品中文字幕一区二区三区| 国产亚洲污的网站| 91麻豆视频网站| 无码av中文一区二区三区桃花岛| 日韩视频123| 成人午夜私人影院| 亚洲一区在线视频观看| 日韩一区二区三区电影在线观看| 韩日av一区二区| 国产精品视频九色porn| 在线观看国产91| 美腿丝袜亚洲三区| 国产精品欧美综合在线| 日本高清不卡aⅴ免费网站| 舔着乳尖日韩一区| 国产欧美一区视频| 欧美性做爰猛烈叫床潮| 久久爱www久久做| 亚洲四区在线观看| 日韩欧美国产午夜精品| 成人aa视频在线观看| 丝袜国产日韩另类美女| 国产日韩欧美不卡| 欧美日韩激情在线| 国产福利精品一区| 亚洲成a人v欧美综合天堂| 国产三级一区二区| 91麻豆精品国产91久久久久久久久 | 欧美日韩三级在线| 国产成人精品www牛牛影视| 亚洲国产精品精华液网站| 久久久久久久久久看片| 欧美伊人久久久久久久久影院| 国产综合色精品一区二区三区| 亚洲乱码国产乱码精品精的特点 | 久久精品国产成人一区二区三区 | 国产在线播精品第三| 亚洲制服丝袜av| 国产精品乱码一区二三区小蝌蚪| 欧美日韩三级视频| 色综合夜色一区| 国产mv日韩mv欧美| 看国产成人h片视频| 亚洲午夜精品一区二区三区他趣| 久久精品视频网| 欧美电影免费观看高清完整版在线观看| 91香蕉视频mp4| 国产999精品久久| 久草热8精品视频在线观看| 香蕉影视欧美成人| 亚洲国产欧美在线| 亚洲卡通欧美制服中文| 亚洲欧洲99久久| 国产欧美日韩在线看| 精品福利在线导航| 日韩一级高清毛片| 欧美日韩另类一区| 欧美一a一片一级一片| 色94色欧美sute亚洲线路一久 | 老司机免费视频一区二区| 亚洲v中文字幕| 亚洲免费在线观看视频| 日韩一区在线播放| 亚洲视频一区二区免费在线观看| 国产色综合一区| 国产女人18毛片水真多成人如厕| 精品久久久久一区| 精品免费国产二区三区| 欧美成人一区二区三区| 欧美哺乳videos| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 色综合咪咪久久| 91伊人久久大香线蕉| 91视频www| 欧美色视频在线| 在线播放国产精品二区一二区四区| 色综合久久综合| 欧美系列一区二区| 欧美疯狂做受xxxx富婆| 欧美不卡在线视频| 欧美激情中文字幕| 亚洲乱码国产乱码精品精98午夜 | 国产精品婷婷午夜在线观看| 国产精品久99| 亚洲综合色自拍一区| 三级亚洲高清视频| 国产又黄又大久久| 91丝袜呻吟高潮美腿白嫩在线观看| 91福利在线导航| 欧美一二三区精品| 中文字幕av一区二区三区| 亚洲精品日产精品乱码不卡| 日韩综合在线视频| 欧美色男人天堂| 欧美喷水一区二区| 久久香蕉国产线看观看99| 国产精品欧美综合在线| 无码av免费一区二区三区试看| 久久精品噜噜噜成人av农村| 成人一区二区三区视频在线观看| 91福利精品第一导航| 日韩一区二区在线看| 中文字幕成人av| 日韩和欧美一区二区三区| 国产精品一区久久久久| 一本久久a久久精品亚洲| 欧美一级片在线看| 亚洲欧美影音先锋| 极品美女销魂一区二区三区 | 欧美色综合网站| 久久久久久9999| 洋洋av久久久久久久一区| 国产在线一区二区| 日本久久电影网| 国产亚洲一区二区三区四区| 亚洲成人免费视频| 成人美女视频在线观看18| 日韩欧美高清在线| 亚洲国产精品久久一线不卡| 国产91丝袜在线播放九色| 7777精品伊人久久久大香线蕉超级流畅 | 久久久亚洲国产美女国产盗摄| 国产精品成人免费| 精品午夜一区二区三区在线观看| 在线区一区二视频| 国产精品天天看| 奇米色777欧美一区二区| 欧美午夜免费电影| 欧美国产一区二区在线观看| 免费成人在线视频观看| 欧美在线观看一区| 国产精品毛片无遮挡高清| 久久国产人妖系列| 欧美另类z0zxhd电影| 亚洲女性喷水在线观看一区| 国产成人自拍网| 亚洲精品在线观| 精品一区二区三区视频| 中文字幕一区av| 成人免费看的视频| 国产无人区一区二区三区| 日本不卡一区二区三区| 欧美性高清videossexo| 亚洲精品一二三四区| 不卡的av电影| 国产精品视频线看| www.亚洲国产| 亚洲欧洲在线观看av| proumb性欧美在线观看| 国产精品二区一区二区aⅴ污介绍| 国产suv精品一区二区6|