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

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

?? os_sem.c

?? 51下的一個操作系統源碼
?? 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一区二区三区免费野_久草精品视频
欧美大片一区二区三区| 亚洲视频一二三| 久久久久久亚洲综合| 中文字幕一区二区不卡| 日产精品久久久久久久性色| 成人精品鲁一区一区二区| 3d动漫精品啪啪1区2区免费| 综合亚洲深深色噜噜狠狠网站| 狠狠色丁香婷婷综合| 欧美日本一区二区在线观看| 亚洲欧美在线aaa| 国产在线国偷精品免费看| 欧美三级日韩在线| 中文字幕av资源一区| 久久精品国产亚洲一区二区三区| 色成人在线视频| 亚洲丝袜精品丝袜在线| 国产很黄免费观看久久| 欧美精品一区二区久久久| 日韩和欧美一区二区三区| 91在线无精精品入口| 国产精品午夜电影| 国产在线精品一区二区夜色| 日韩视频一区二区三区在线播放| 亚洲国产精品久久久久婷婷884| 99精品视频在线免费观看| 日本一区二区电影| 国产成人精品一区二| 国产三级欧美三级日产三级99| 久久精品国产一区二区三区免费看| 91精品国产综合久久精品图片| 亚洲一本大道在线| 欧洲一区二区三区在线| 一区二区高清视频在线观看| 91欧美激情一区二区三区成人| |精品福利一区二区三区| 99天天综合性| 亚洲精品乱码久久久久久久久| yourporn久久国产精品| 国产精品久久久久久户外露出| 成人av资源网站| 136国产福利精品导航| 99re这里都是精品| 亚洲色图制服诱惑| 欧美日韩视频一区二区| 日韩在线一二三区| 久久这里只有精品6| 成人午夜视频在线| 一区二区三区四区亚洲| 欧美日韩一区二区三区四区五区| 婷婷国产v国产偷v亚洲高清| 欧美mv和日韩mv国产网站| 国产一区二区精品久久99| 中文一区二区完整视频在线观看| 91亚洲精品久久久蜜桃| 日日夜夜免费精品视频| 精品国产制服丝袜高跟| 99re这里都是精品| 丝袜亚洲另类丝袜在线| www国产成人免费观看视频 深夜成人网| 国产麻豆欧美日韩一区| 一区二区三区欧美在线观看| 日韩一区二区视频| 成人蜜臀av电影| 一区二区三区精品视频| 欧美大片在线观看一区二区| 99久久精品免费| 琪琪久久久久日韩精品| 国产精品第13页| 欧美日韩一二三区| 高潮精品一区videoshd| 视频在线观看一区| 国产精品剧情在线亚洲| 91麻豆精品国产91| 91在线观看视频| 精品亚洲国产成人av制服丝袜| 亚洲欧美日韩人成在线播放| 精品理论电影在线观看 | 91麻豆蜜桃一区二区三区| 香蕉影视欧美成人| 亚洲视频一区在线观看| 欧美va在线播放| 欧美性大战久久| 丁香婷婷综合网| 久久成人免费日本黄色| 亚洲综合丁香婷婷六月香| 久久精品欧美日韩精品| 欧美一区二区日韩| 日本久久一区二区三区| 国产91精品在线观看| 美女视频黄久久| 亚洲成人av电影在线| 亚洲人成小说网站色在线 | 蜜桃一区二区三区在线| 一区二区三区精品视频| 国产精品色哟哟| 欧美xxxxxxxx| 欧美二区乱c少妇| 在线免费一区三区| 91免费视频观看| 国产成人精品影视| 国产精品99久久久久久似苏梦涵| 日本91福利区| 日韩高清在线不卡| 午夜久久久久久久久久一区二区| 国产精品伦一区二区三级视频| 久久香蕉国产线看观看99| 欧美xxxxx牲另类人与| 91麻豆精品国产91久久久久久久久 | 国产精品1区2区| 国产一区二区在线观看免费| 毛片不卡一区二区| 美女视频一区二区| 免费成人深夜小野草| 麻豆一区二区99久久久久| 免费成人小视频| 国产主播一区二区三区| 韩国av一区二区三区| 国产毛片一区二区| 国产99久久久久| av男人天堂一区| 91年精品国产| 欧美三级中文字| 日韩欧美一区在线| 26uuu国产在线精品一区二区| 久久嫩草精品久久久精品| 久久亚洲精华国产精华液 | 欧美剧情片在线观看| 欧美一级日韩免费不卡| 亚洲精品一区二区三区蜜桃下载| 精品捆绑美女sm三区| 日本一区免费视频| 亚洲欧美另类小说| 亚洲成人免费av| 美女国产一区二区三区| 国产精品1区2区3区| 色综合久久天天| 91超碰这里只有精品国产| 26uuu国产电影一区二区| 国产精品日日摸夜夜摸av| 一区二区三区免费在线观看| 日本美女一区二区三区视频| 国产美女av一区二区三区| 91热门视频在线观看| 91精品国产综合久久香蕉的特点| 欧美变态tickle挠乳网站| 国产精品看片你懂得| 视频一区二区中文字幕| 国产成人aaa| 欧美日韩国产美女| 欧美国产日韩在线观看| 亚洲成人资源网| 国产91对白在线观看九色| 欧美日韩精品一二三区| 中文字幕精品一区二区精品绿巨人| 亚洲综合激情另类小说区| 国产伦精一区二区三区| 在线观看av一区| 久久久国产午夜精品| 亚洲成人av电影| www.日韩大片| 久久综合狠狠综合久久综合88| 亚洲免费av网站| 国产精品一二三四五| 8v天堂国产在线一区二区| 亚洲天堂福利av| 国产美女娇喘av呻吟久久| 欧美日本国产一区| 亚洲天天做日日做天天谢日日欢 | 国产福利一区二区三区视频| 色先锋资源久久综合| 国产色91在线| 日韩电影一二三区| 日本二三区不卡| 国产精品久久三| 国产高清在线精品| 精品美女一区二区| 丝袜美腿亚洲一区| 欧美特级限制片免费在线观看| 中文字幕av不卡| 国产一区二区三区观看| 欧美日韩视频在线观看一区二区三区| 日本一区二区免费在线观看视频 | 欧美一区二区三区爱爱| 亚洲尤物视频在线| 91麻豆国产在线观看| 中文字幕成人在线观看| 国产福利91精品一区| 26uuu欧美| 国精产品一区一区三区mba桃花| 欧美精品久久天天躁| 性久久久久久久久| 欧美日韩国产高清一区二区三区| 一区二区在线观看视频 | 国产高清不卡一区| 精品国产成人系列| 精品一区二区三区影院在线午夜| 日韩写真欧美这视频| 乱一区二区av| www国产精品av|