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

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

?? os_sem.c

?? uCOS-II源碼公開的實時嵌入式操作系統.rar
?? 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一区二区三区免费野_久草精品视频
在线免费观看日韩欧美| 日韩一区精品视频| 国产99一区视频免费| 久久久久国产免费免费 | 精品久久五月天| 久久99久久久久久久久久久| 欧美一区二区免费视频| 国内偷窥港台综合视频在线播放| 精品久久五月天| 国产iv一区二区三区| 亚洲日本在线天堂| 欧美日韩不卡一区二区| 天天操天天综合网| 欧美精品一区在线观看| 国产成人午夜精品影院观看视频| 国产精品久久久久精k8| 欧美羞羞免费网站| 国产风韵犹存在线视精品| 国产欧美一区二区三区鸳鸯浴| www.亚洲人| 亚洲成av人片一区二区梦乃| 日韩欧美卡一卡二| 不卡在线视频中文字幕| 亚洲福利视频一区二区| 精品国产一区二区三区四区四| 岛国一区二区在线观看| 香蕉影视欧美成人| 国产欧美日韩在线| 欧美日韩精品三区| 国产一区二区成人久久免费影院| 最新高清无码专区| 欧美一区二区久久久| 成人网男人的天堂| 美腿丝袜一区二区三区| 中文字幕在线播放不卡一区| 欧美裸体bbwbbwbbw| 国产成人午夜片在线观看高清观看| 亚洲一区二区视频在线观看| 精品国产网站在线观看| 欧美亚洲丝袜传媒另类| 国产成人无遮挡在线视频| 亚洲成人精品一区二区| 国产精品视频一二三| 555夜色666亚洲国产免| av中文字幕一区| 国内精品免费在线观看| 亚洲成人av一区二区| 国产精品毛片无遮挡高清| 欧美一二三区在线| 欧洲另类一二三四区| 高清久久久久久| 激情欧美日韩一区二区| 亚洲一区二区三区美女| 国产精品妹子av| 337p粉嫩大胆噜噜噜噜噜91av| 欧美三级欧美一级| 色综合一区二区| 成人av集中营| 国产电影一区二区三区| 久久精品72免费观看| 日韩av中文字幕一区二区三区 | 99精品黄色片免费大全| 久久爱另类一区二区小说| 亚洲福利一区二区三区| 亚洲色图欧美偷拍| 国产精品区一区二区三区| 精品久久久网站| 欧美一二区视频| 欧美一区永久视频免费观看| 精品视频1区2区3区| 色8久久人人97超碰香蕉987| hitomi一区二区三区精品| 国产精品影视网| 国产成人在线观看免费网站| 捆绑紧缚一区二区三区视频| 久久国产视频网| 国产精品一区二区久激情瑜伽| 九一九一国产精品| 国产精品亚洲一区二区三区在线 | 亚洲高清免费视频| 亚洲三级视频在线观看| 亚洲嫩草精品久久| 亚洲777理论| 日本中文字幕一区二区视频 | 色琪琪一区二区三区亚洲区| 99精品桃花视频在线观看| 粉嫩13p一区二区三区| 成人激情文学综合网| av高清久久久| 欧美在线高清视频| 欧美日韩免费电影| 欧美日韩mp4| 精品久久久影院| 国产欧美一区二区三区鸳鸯浴| 国产精品久久久久久久裸模| 中文字幕中文字幕在线一区| 亚洲精品乱码久久久久久黑人| 夜夜嗨av一区二区三区中文字幕| 亚洲激情自拍偷拍| 视频在线观看91| 精品一区二区三区久久| 国产成人啪免费观看软件| 91色视频在线| 在线综合亚洲欧美在线视频 | 精品国产精品网麻豆系列 | 中文字幕综合网| 亚洲图片有声小说| 男男gaygay亚洲| 国产美女主播视频一区| 99久久er热在这里只有精品15| 欧美亚洲国产一区二区三区| 69久久夜色精品国产69蝌蚪网| wwww国产精品欧美| 亚洲激情校园春色| 久久国产精品99久久久久久老狼 | 日本精品一区二区三区高清 | 亚洲日本电影在线| 日韩激情视频在线观看| 国产成人在线视频网站| 91精品办公室少妇高潮对白| 欧美精品九九99久久| 国产免费成人在线视频| 午夜电影网一区| 国产一区二区三区在线看麻豆| 色综合天天做天天爱| 欧美电影免费提供在线观看| 1024成人网| 国产伦精一区二区三区| 欧美日韩在线播放| 国产精品素人视频| 视频一区中文字幕| 色老头久久综合| 久久免费看少妇高潮| 一区二区激情小说| 国内精品国产三级国产a久久| 在线观看一区二区精品视频| 久久一夜天堂av一区二区三区| 亚洲影视在线播放| av在线播放成人| 久久久综合网站| 奇米一区二区三区| 色综合久久久久综合99| 久久综合九色综合97婷婷女人| 亚洲一区二区在线观看视频| 国产精品夜夜嗨| 欧美r级电影在线观看| 一区二区三区四区蜜桃| 成人高清在线视频| 精品国产免费视频| 日本最新不卡在线| 欧美日本乱大交xxxxx| 亚洲欧美二区三区| 不卡的电影网站| 欧美精彩视频一区二区三区| 人人狠狠综合久久亚洲| 884aa四虎影成人精品一区| 亚洲精选在线视频| av在线不卡电影| 亚洲图片激情小说| 91麻豆国产自产在线观看| 国产精品无圣光一区二区| 国产在线国偷精品产拍免费yy| 51精品视频一区二区三区| 亚洲国产另类av| 欧美午夜影院一区| 亚洲国产日韩精品| 欧美亚洲综合在线| 亚洲午夜精品在线| 欧美手机在线视频| 五月天激情小说综合| 欧美日韩在线三区| 日韩成人一区二区| 日韩欧美黄色影院| 看片的网站亚洲| 久久久不卡网国产精品一区| 韩国v欧美v日本v亚洲v| 日韩网站在线看片你懂的| 毛片av一区二区三区| 欧美精品一区在线观看| 国产成人精品三级麻豆| 国产女同性恋一区二区| 成人性生交大片免费看在线播放| 国产精品国产三级国产有无不卡| eeuss鲁片一区二区三区| 国产精品不卡在线观看| 欧美三级资源在线| 免费成人在线视频观看| 久久综合狠狠综合久久激情| 国产91对白在线观看九色| 亚洲欧美另类小说| 911精品国产一区二区在线| 蜜臂av日日欢夜夜爽一区| 久久午夜电影网| 91色porny在线视频| 国模一区二区三区白浆| 久久久99免费| 91精品福利在线| 国产一区二区三区在线观看免费视频 | av电影天堂一区二区在线观看| 日韩伦理av电影|