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

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

?? os_sem.c

?? ucos ii xzdfdsf dafa
?? 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
*********************************************************************************************************
*/
#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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久电影网电视剧免费观看| 丰满少妇在线播放bd日韩电影| 久久五月婷婷丁香社区| 99久久免费精品| 精品午夜久久福利影院| 视频一区国产视频| 亚洲靠逼com| 国产日本欧美一区二区| 欧美一级一区二区| 91福利视频网站| 成人激情免费网站| 国内精品久久久久影院色| 午夜精品福利一区二区蜜股av| 国产精品久久免费看| 精品国产91洋老外米糕| 欧美日韩亚洲综合| 日本韩国精品在线| av在线不卡免费看| 国产很黄免费观看久久| 蜜臀91精品一区二区三区| 亚洲国产精品一区二区久久| 亚洲人成网站色在线观看| 亚洲国产精品99久久久久久久久| 欧美电影免费观看高清完整版在线 | 国产精品一区在线观看你懂的| 亚洲电影中文字幕在线观看| 亚洲欧美日韩国产另类专区| 中文字幕在线不卡国产视频| 久久精品人人爽人人爽| 日韩欧美在线网站| 日韩精品一区二区三区四区视频| 91精品国产综合久久福利| 欧美日韩亚洲综合在线 | 美女一区二区久久| 日韩国产精品久久| 日韩高清欧美激情| 免费高清在线一区| 久久精品理论片| 六月婷婷色综合| 美女精品自拍一二三四| 麻豆精品在线观看| 久久99精品久久久久久久久久久久| 久久精品久久99精品久久| 久草中文综合在线| 国产精品综合av一区二区国产馆| 九九精品一区二区| 国产精品一区二区黑丝| 成人黄色免费短视频| 91麻豆视频网站| 欧洲一区在线电影| 日韩三级电影网址| 2023国产精品自拍| 中文字幕乱码一区二区免费| 中文字幕在线不卡一区二区三区| 亚洲精品ww久久久久久p站| 午夜久久久久久| 久久99最新地址| 国产成人一区在线| 91麻豆自制传媒国产之光| 欧美色视频在线| 日韩天堂在线观看| 国产亚洲精品福利| 亚洲视频你懂的| 奇米四色…亚洲| 丰满少妇在线播放bd日韩电影| 色国产精品一区在线观看| 欧美日韩激情一区二区| 欧美精品一区二区三区视频| 亚洲国产成人在线| 亚洲国产精品欧美一二99| 久久成人免费网| 99久久精品国产导航| 欧美一区二区在线不卡| 国产欧美中文在线| 亚洲国产日韩综合久久精品| 久久av老司机精品网站导航| youjizz久久| 91精品国产高清一区二区三区蜜臀 | 久久久久久久久99精品| 一区二区欧美视频| 国产一区二区三区久久悠悠色av| av资源站一区| 欧美白人最猛性xxxxx69交| 国产精品第五页| 久久99国产乱子伦精品免费| 91在线国产观看| 精品久久人人做人人爰| 亚洲黄色av一区| 国产精品77777竹菊影视小说| 欧美日韩色一区| 国产精品视频一区二区三区不卡| 日韩av电影一区| 色妞www精品视频| 久久综合九色综合欧美就去吻 | 精品国内二区三区| 亚洲精品欧美综合四区| 黑人巨大精品欧美黑白配亚洲| 色综合天天综合| 久久这里只精品最新地址| 亚洲影院久久精品| 高清久久久久久| 欧美一区二区三区公司| 亚洲欧美日韩久久精品| 国产精品一区二区在线看| 欧美一区二区三区视频免费 | 日韩欧美综合在线| 亚洲成av人在线观看| 91香蕉视频在线| 国产亚洲欧洲997久久综合 | 精品一区二区三区视频在线观看| 欧美写真视频网站| 中文字幕中文字幕在线一区 | 亚洲精品午夜久久久| 国产大陆亚洲精品国产| 日韩欧美在线网站| 亚洲一本大道在线| 一本到高清视频免费精品| 欧美激情在线一区二区三区| 久国产精品韩国三级视频| 日韩免费观看高清完整版在线观看| 亚洲一级二级在线| 一本久道久久综合中文字幕| 亚洲欧美综合在线精品| 成人激情图片网| 中国色在线观看另类| 国产精品亚洲人在线观看| 欧美成人性战久久| 五月婷婷综合网| 欧美日韩高清在线| 婷婷丁香久久五月婷婷| 欧美日韩aaaaa| 亚洲成精国产精品女| 欧美日韩国产高清一区二区| 亚洲综合免费观看高清完整版在线| 91国偷自产一区二区三区观看| 亚洲欧美精品午睡沙发| 一本一本久久a久久精品综合麻豆| √…a在线天堂一区| 色丁香久综合在线久综合在线观看| 国产精品久99| 在线中文字幕一区| 午夜日韩在线观看| 7777精品伊人久久久大香线蕉最新版| 亚洲成av人影院在线观看网| 欧美日韩一区二区不卡| 肉色丝袜一区二区| 精品国产伦一区二区三区观看方式| 国产一区在线精品| 国产精品久久久久久久浪潮网站 | 一区二区在线观看免费| 欧美在线你懂的| 婷婷综合另类小说色区| 日韩免费看的电影| 国产成人综合精品三级| 亚洲男人都懂的| 欧美狂野另类xxxxoooo| 久久69国产一区二区蜜臀| 国产欧美一区二区精品忘忧草| 99热在这里有精品免费| 亚洲国产精品视频| www国产亚洲精品久久麻豆| 国产成人综合自拍| 亚洲午夜av在线| xnxx国产精品| 在线亚洲一区二区| 美国欧美日韩国产在线播放| 中文字幕av不卡| 欧美日韩一区二区三区在线| 九色|91porny| 亚洲精品国产成人久久av盗摄| 欧美一级淫片007| 成人免费视频caoporn| 亚洲成va人在线观看| 国产欧美日韩另类一区| 欧美三级一区二区| 国产一区欧美日韩| 亚洲国产精品精华液网站| 久久先锋影音av| 欧美中文一区二区三区| 国产一区二区三区四区五区入口 | 亚洲天堂a在线| 欧美一区二区高清| 91一区二区在线| 久久99国产精品尤物| 亚洲黄色小说网站| 国产日韩欧美a| 欧美电影一区二区三区| 岛国一区二区三区| 蜜臀a∨国产成人精品| 亚洲摸摸操操av| 2019国产精品| 欧美一区二区三区免费在线看| 99热99精品| 国产一区视频网站| 日韩av在线播放中文字幕| 亚洲欧美一区二区视频| 精品国产乱码久久久久久牛牛| 欧美午夜影院一区| av一区二区三区| 国产一区二区精品久久99|