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

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

?? os_sem.c

?? ucos2.52多處理器平臺移植源代碼
?? 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一区二区三区免费野_久草精品视频
国产天堂亚洲国产碰碰| 欧美日韩成人综合| 捆绑调教一区二区三区| 亚洲欧美在线另类| 中文欧美字幕免费| 久久免费美女视频| 欧美不卡激情三级在线观看| 欧美性猛交xxxx乱大交退制版| 不卡欧美aaaaa| 免费观看成人av| 免费高清在线一区| 免费观看日韩电影| 亚洲成人你懂的| 亚洲永久免费视频| 亚洲一区二区在线观看视频| 亚洲一区二区三区四区五区中文| 亚洲啪啪综合av一区二区三区| 中文字幕一区日韩精品欧美| 综合久久国产九一剧情麻豆| 日本不卡一二三| 日韩中文字幕亚洲一区二区va在线 | 手机精品视频在线观看| 亚洲成av人片一区二区梦乃| 亚洲高清不卡在线| 日韩电影在线观看一区| 久久精品国产久精国产| 国产一区欧美日韩| 国产成人超碰人人澡人人澡| 91在线高清观看| 欧美三电影在线| 欧美不卡激情三级在线观看| 久久精品一级爱片| 亚洲色欲色欲www| 午夜精品久久久久久久| 久草这里只有精品视频| 成人夜色视频网站在线观看| 91麻豆成人久久精品二区三区| 日本韩国精品在线| 日韩视频一区二区三区| 久久久久亚洲蜜桃| 亚洲一区二区三区中文字幕在线| 蜜臀av一区二区| 成人爽a毛片一区二区免费| 欧洲中文字幕精品| 久久综合色之久久综合| 亚洲欧洲另类国产综合| 青娱乐精品视频| 国产91精品久久久久久久网曝门 | 日韩伦理免费电影| 日韩国产欧美在线观看| 高清不卡在线观看| 91麻豆精品国产91久久久| 国产拍揄自揄精品视频麻豆| 亚洲中国最大av网站| 国产成人精品一区二区三区四区 | 久久噜噜亚洲综合| 亚洲综合免费观看高清完整版| 久久国产精品免费| 欧美性欧美巨大黑白大战| 久久精品免费在线观看| 亚洲成人一区二区在线观看| www.亚洲色图| 欧美大尺度电影在线| 亚洲国产日韩a在线播放| 国产凹凸在线观看一区二区| 555夜色666亚洲国产免| 亚洲日本欧美天堂| 国产91清纯白嫩初高中在线观看| 欧美精选一区二区| 一区二区三区欧美激情| 成人小视频在线| 精品成人一区二区| 国产婷婷色一区二区三区在线| 亚洲成人av中文| 成人午夜又粗又硬又大| 欧美另类变人与禽xxxxx| 亚洲欧洲一区二区在线播放| 国产精品99久久久久| 日韩天堂在线观看| 麻豆精品在线看| 91精品欧美久久久久久动漫| 亚洲成人自拍网| 日韩精品一区二区三区swag | 国产尤物一区二区| 欧美一区二区三区不卡| 首页欧美精品中文字幕| 欧美精品日韩精品| 亚洲国产人成综合网站| 欧美一a一片一级一片| 国产欧美一区二区三区鸳鸯浴| 日韩不卡一二三区| 日韩欧美在线1卡| 久久99精品久久久久久动态图 | 色香蕉久久蜜桃| 夜夜嗨av一区二区三区网页| 欧美天堂一区二区三区| 亚洲二区在线观看| 88在线观看91蜜桃国自产| 日日摸夜夜添夜夜添国产精品| 日韩一区二区在线看| 蜜臀久久久久久久| 欧美精品一区男女天堂| 国产美女视频91| 自拍偷拍国产亚洲| 在线一区二区视频| 日本91福利区| 日韩一级完整毛片| 国产精品1024| 亚洲女人小视频在线观看| 一本色道久久综合狠狠躁的推荐| 亚洲午夜影视影院在线观看| 日韩午夜精品视频| 粉嫩久久99精品久久久久久夜| 日韩毛片一二三区| 欧美一二三区在线观看| 国产91精品在线观看| 亚洲一区二区三区国产| 精品国产乱码久久久久久夜甘婷婷 | 日韩毛片视频在线看| 欧美另类videos死尸| 国产自产2019最新不卡| 《视频一区视频二区| 欧美日韩亚洲综合一区二区三区| 精品一区二区在线看| 亚洲欧美综合色| 日韩精品专区在线影院观看| 99精品欧美一区二区三区小说| 亚洲成人动漫av| 国产性做久久久久久| 一本色道久久综合精品竹菊| 国产一区二区精品久久| 午夜精彩视频在线观看不卡| 亚洲国产成人午夜在线一区| 日韩一级片网址| 91久久免费观看| 国产精品一区二区91| 日韩精品1区2区3区| 亚洲色欲色欲www| 久久久精品中文字幕麻豆发布| 欧洲国内综合视频| 波多野结衣在线aⅴ中文字幕不卡| 奇米精品一区二区三区在线观看 | 国产一区二区三区观看| 亚洲成人av在线电影| 亚洲欧美在线另类| 欧美一级片在线看| 欧洲生活片亚洲生活在线观看| 久久成人精品无人区| 午夜欧美视频在线观看 | 精品sm捆绑视频| 欧美色精品天天在线观看视频| 日本福利一区二区| 91蜜桃在线观看| 91国偷自产一区二区开放时间| 一本色道**综合亚洲精品蜜桃冫 | 亚洲一级不卡视频| 亚洲va天堂va国产va久| 偷拍日韩校园综合在线| 日本vs亚洲vs韩国一区三区二区| 五月综合激情日本mⅴ| 偷拍与自拍一区| 久久91精品国产91久久小草| 国产毛片精品视频| 成人在线视频一区| 91日韩一区二区三区| 欧美性一级生活| 日韩欧美一级精品久久| 久久丝袜美腿综合| 国产精品久久久久久久午夜片 | 欧美久久久一区| 亚洲精品一区二区三区香蕉 | 美女mm1313爽爽久久久蜜臀| 精品一区二区三区免费毛片爱| 国产麻豆9l精品三级站| 99九九99九九九视频精品| 91高清视频免费看| 欧美成人bangbros| 国产精品国产三级国产aⅴ中文| 亚洲一区二区三区四区的| 久久精品国产99国产| 99在线精品视频| 欧美一区欧美二区| 国产精品女主播av| 午夜私人影院久久久久| 国产制服丝袜一区| 欧洲另类一二三四区| 精品日韩在线观看| 亚洲欧洲日产国产综合网| 蜜臀va亚洲va欧美va天堂| 成人国产精品免费观看动漫| 欧美日韩二区三区| 国产精品色哟哟网站| 亚洲成在人线免费| eeuss鲁片一区二区三区在线看 | 韩国v欧美v亚洲v日本v| 91论坛在线播放| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品天干天干在线综合| 午夜久久久久久| 99久久久无码国产精品|