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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? os_sem.c

?? 新版本ucosii移植
?? C
字號(hào):
/*
*********************************************************************************************************
*                                                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 *ppdata) 
{
    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);
    }
    ppdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &ppdata->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    ppdata->OSCnt      = pevent->OSEventCnt;                /* Get semaphore count                      */
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
#endif

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合精品自拍| 亚洲欧美综合在线精品| 成人高清视频免费观看| 亚洲日本va在线观看| 日韩欧美一二三区| 成人高清免费观看| 日本不卡一区二区三区| 亚洲三级在线看| 久久久亚洲高清| 在线91免费看| 欧美日韩三级一区| 91一区二区三区在线观看| 久久av资源网| 日韩不卡一区二区| 亚洲欧美一区二区三区孕妇| 欧美一区二区私人影院日本| 韩国理伦片一区二区三区在线播放 | 欧美一区二区在线免费播放| www.综合网.com| 国产mv日韩mv欧美| 免费看欧美女人艹b| 视频在线观看国产精品| 亚洲综合视频网| 亚洲欧美国产三级| 一区二区三区丝袜| 亚洲自拍偷拍图区| 亚洲一区二区在线免费观看视频| 中日韩免费视频中文字幕| 2023国产精品视频| 欧美高清在线一区| 国产精品久久久久久福利一牛影视 | 亚洲国产精品久久人人爱| 亚洲成在线观看| 日本亚洲免费观看| 麻豆成人91精品二区三区| 韩国精品免费视频| 91一区二区在线| 色综合色综合色综合| 欧美综合亚洲图片综合区| 欧美在线你懂的| 久久亚洲精品小早川怜子| 精品国产免费久久| 国产精品嫩草久久久久| 亚洲国产精品久久艾草纯爱| 日产欧产美韩系列久久99| 国产在线播放一区| 91国在线观看| 精品久久久久久久久久久院品网| 国产亚洲一区二区三区在线观看| 日本一区二区在线不卡| 一区2区3区在线看| 国产一区 二区| 国产成人日日夜夜| 欧美日韩免费一区二区三区| 成人永久aaa| 欧美午夜精品免费| 久久久久久久久蜜桃| 亚洲午夜电影网| 另类小说视频一区二区| 91香蕉国产在线观看软件| 久久综合一区二区| 亚洲电影激情视频网站| 国产.欧美.日韩| 欧美丰满嫩嫩电影| 亚洲图片另类小说| 国产一区 二区| 欧美在线视频不卡| 中文字幕av资源一区| 偷拍亚洲欧洲综合| 色综合色狠狠天天综合色| 久久毛片高清国产| 日本亚洲天堂网| 色吊一区二区三区 | 久久99精品久久久久婷婷| 91美女在线视频| 国产三级欧美三级| 日本一区中文字幕| 欧美人妇做爰xxxⅹ性高电影| 国产精品久久久久久福利一牛影视 | 精品一区二区精品| 欧美色精品天天在线观看视频| 国产精品女同一区二区三区| 久久国产日韩欧美精品| 欧美日韩国产一区二区三区地区| 国产精品―色哟哟| 国产一区二区不卡在线 | 亚洲精品国产精华液| 成人综合婷婷国产精品久久免费| 精品久久久久久久久久久久久久久久久 | 国产高清无密码一区二区三区| 日韩欧美在线1卡| 亚洲成av人片在线| 在线精品视频一区二区三四| 亚洲欧美国产三级| 一本一道久久a久久精品| 中文字幕日韩av资源站| 成人免费视频一区| 中文字幕精品—区二区四季| 国产精品综合一区二区| 久久影院午夜论| 国产一区福利在线| 久久精品综合网| 国产精品99久久久久久久女警| 精品久久免费看| 国产精品一区二区在线观看网站| 久久综合中文字幕| 国产福利一区二区三区视频| 欧美国产一区在线| www.亚洲免费av| 亚洲欧美日韩一区二区三区在线观看| 96av麻豆蜜桃一区二区| 最近中文字幕一区二区三区| 91亚洲精品久久久蜜桃网站| 亚洲精品国产成人久久av盗摄| 91高清视频在线| 夜夜嗨av一区二区三区| 欧美日韩亚洲高清一区二区| 青青草成人在线观看| 欧美成人一区二区三区片免费| 精品系列免费在线观看| 久久综合色之久久综合| 国产精品一区三区| 国产精品家庭影院| 91丨porny丨首页| 亚洲电影一区二区| 欧美变态凌虐bdsm| 国产伦精一区二区三区| 国产精品嫩草影院com| 91福利视频在线| 喷水一区二区三区| 欧美激情在线一区二区| 色老头久久综合| 蜜臀av一区二区在线观看| 久久免费偷拍视频| 一本大道综合伊人精品热热| 亚洲 欧美综合在线网络| 精品国产乱码久久久久久图片| 岛国av在线一区| 亚洲国产精品久久久久秋霞影院| 日韩欧美第一区| 成人性生交大片免费看在线播放| 一区二区成人在线| 精品国产污污免费网站入口| av资源站一区| 日本美女视频一区二区| 中文字幕免费一区| 欧美美女一区二区三区| 国产露脸91国语对白| 一区二区三区精品视频在线| 日韩一区二区免费在线观看| 成人av资源站| 麻豆成人久久精品二区三区小说| 中文字幕免费不卡在线| 欧美精选午夜久久久乱码6080| 国精产品一区一区三区mba视频| 亚洲精品欧美专区| 精品国产一区二区在线观看| 在线中文字幕不卡| 韩国三级中文字幕hd久久精品| 亚洲乱码国产乱码精品精98午夜 | 欧美日韩国产三级| 成人精品一区二区三区四区| 日韩**一区毛片| 成人欧美一区二区三区视频网页| 日韩三级伦理片妻子的秘密按摩| 99国产精品久久久久久久久久久| 麻豆成人91精品二区三区| 亚洲乱码中文字幕综合| 久久女同精品一区二区| 欧美日韩日日骚| 波波电影院一区二区三区| 毛片基地黄久久久久久天堂| 一区二区三区四区乱视频| 国产欧美日韩视频在线观看| 欧美老肥妇做.爰bbww| 97se亚洲国产综合自在线| 国产精品66部| 三级亚洲高清视频| 亚洲精品乱码久久久久久日本蜜臀| 精品国产乱码91久久久久久网站| 在线观看视频一区二区| av成人免费在线观看| 国产精品资源网站| 精品一区二区三区视频 | 欧美日本精品一区二区三区| 97se亚洲国产综合在线| 成人激情免费网站| 国产一区二区三区黄视频| 日日嗨av一区二区三区四区| 亚洲在线观看免费| ...av二区三区久久精品| 久久久久99精品一区| 日韩女同互慰一区二区| 欧美一区二区三区免费视频 | 亚洲综合免费观看高清完整版在线| 中文字幕欧美激情| 国产日韩欧美不卡| 国产亚洲精品福利| 久久久精品2019中文字幕之3| 日韩欧美精品三级|