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

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

?? os_sem.c

?? uCOS_II在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
*********************************************************************************************************
*/

INT16U OSSemAccept (OS_EVENT DT_XDATA *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                        */
}

/*$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 DT_XDATA *OSSemCreate (INT16U cnt) REENTRANT
{
    OS_EVENT DT_XDATA *pevent;


    OS_ENTER_CRITICAL();
    pevent = OSEventFreeList;                              /* Get next free event control block        */
    if (OSEventFreeList != (OS_EVENT DT_XDATA *)0) {                /* See if pool of free ECB pool was empty   */
        OSEventFreeList = (OS_EVENT DT_XDATA *)OSEventFreeList->OSEventPtr;
    }
    OS_EXIT_CRITICAL();
    if (pevent != (OS_EVENT DT_XDATA *)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 DT_XDATA *pevent, INT16U timeout, INT8U DT_XDATA *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 DT_XDATA *)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 DT_XDATA *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 DT_XDATA *)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
*
*              ppdata         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 DT_XDATA *pevent, OS_SEM_DATA DT_XDATA *ppdata) REENTRANT
{
    INT8U  i;
    INT8U DT_XDATA *psrc;
    INT8U DT_XDATA *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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文一区在线播放| 午夜精品免费在线| 五月天欧美精品| 国产1区2区3区精品美女| 在线视频一区二区三区| 欧美精品一区二区三区久久久| 国产精品久久久久久久久图文区| 日韩成人av影视| 色综合久久久久网| 91成人网在线| 国产精品久久久久久久午夜片 | 色一区在线观看| 久久先锋影音av鲁色资源 | 欧美激情一区二区在线| 蜜臀久久99精品久久久久宅男| 91丨九色丨国产丨porny| 26uuu精品一区二区| 蜜桃av噜噜一区二区三区小说| 欧美性猛交一区二区三区精品| 国产亚洲综合在线| 久久超级碰视频| 欧美成人a视频| 蜜桃91丨九色丨蝌蚪91桃色| 欧美丰满嫩嫩电影| 亚洲sss视频在线视频| 色婷婷狠狠综合| 一区二区三区欧美亚洲| 成人动漫中文字幕| 国产精品色在线| 国产xxx精品视频大全| 精品少妇一区二区三区日产乱码 | 亚洲视频一区二区在线观看| 国产精品一区二区男女羞羞无遮挡| 日韩一区二区在线免费观看| 日韩成人免费电影| 欧美成人精品福利| 激情综合色播五月| 久久免费精品国产久精品久久久久| 久久精品久久久精品美女| 欧美一区二区国产| 国内外成人在线视频| 精品国产1区二区| 国产成人综合在线观看| 欧美激情一区二区三区| 色综合久久久久综合体| 亚洲国产成人91porn| 91麻豆精品91久久久久久清纯| 日韩电影免费在线看| 精品国产青草久久久久福利| 国产精品自在在线| 亚洲视频一区二区在线| 欧美性一二三区| 精品一区二区在线看| 亚洲国产精品ⅴa在线观看| 91免费在线视频观看| 亚洲电影一区二区| 精品国产乱子伦一区| 盗摄精品av一区二区三区| 亚洲精品高清视频在线观看| 欧美一区二区视频在线观看 | 日韩免费在线观看| 国产成人亚洲综合色影视| 亚洲视频在线观看一区| 这里只有精品99re| 丁香婷婷综合激情五月色| 亚洲精品久久嫩草网站秘色| 538在线一区二区精品国产| 国产永久精品大片wwwapp| 亚洲欧美视频一区| 91精品国产综合久久蜜臀| 国产高清在线精品| 亚洲国产婷婷综合在线精品| 日韩精品中文字幕一区二区三区| 成人动漫av在线| 美女在线视频一区| 亚洲欧美另类小说视频| 欧美电影免费观看完整版| 99精品热视频| 久久99久久久久久久久久久| 亚洲欧美综合网| 欧美电影免费观看高清完整版在| 一本色道**综合亚洲精品蜜桃冫| 日本不卡视频在线| 一区二区在线看| 国产偷国产偷精品高清尤物| 欧美日韩国产综合草草| 成人激情图片网| 韩国av一区二区三区在线观看| 亚洲精品久久久蜜桃| 国产蜜臀av在线一区二区三区| 91精品国产品国语在线不卡| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 欧美一级艳片视频免费观看| 成人黄动漫网站免费app| 久久99精品国产| 日韩二区三区在线观看| 亚洲午夜羞羞片| 亚洲视频一区在线观看| 欧美国产精品v| 精品99999| 欧美一区二区观看视频| 欧美三级日韩在线| 日本丶国产丶欧美色综合| 成人国产精品免费网站| 国产精品一级片| 精品无人码麻豆乱码1区2区 | 日韩一区二区三| 欧美日韩国产另类不卡| 色8久久精品久久久久久蜜 | 亚洲欧美在线视频观看| 国产性天天综合网| 久久亚洲免费视频| 国产亚洲欧美激情| 国产色综合久久| 久久精品这里都是精品| 久久伊人中文字幕| 欧美激情艳妇裸体舞| 国产调教视频一区| 中文字幕精品三区| 亚洲欧美一区二区三区国产精品| 综合分类小说区另类春色亚洲小说欧美| 成人一区二区三区视频在线观看| 日韩精品久久理论片| 亚洲大型综合色站| 午夜精品久久一牛影视| 亚洲h动漫在线| 日本成人在线电影网| 日本成人在线不卡视频| 国产在线视频精品一区| 成人av午夜电影| 91蝌蚪porny九色| 欧美无砖砖区免费| 日韩一区二区三区在线观看| 欧美电视剧在线观看完整版| 国产婷婷色一区二区三区四区| 国产精品超碰97尤物18| 亚洲精品老司机| 青青草成人在线观看| 韩国在线一区二区| 色婷婷精品大视频在线蜜桃视频| 欧美日韩电影在线| 2024国产精品| 有码一区二区三区| 美女在线观看视频一区二区| 国产91在线观看丝袜| 色综合久久99| 精品盗摄一区二区三区| 国产精品久久夜| 日本网站在线观看一区二区三区 | 蜜臀av一区二区在线免费观看| 国产精品一区二区在线看| 91丨九色丨蝌蚪丨老版| 欧美一级理论性理论a| 国产精品乱码一区二三区小蝌蚪| 亚洲一区二区三区视频在线| 久草精品在线观看| 日本久久一区二区| 亚洲精品在线免费播放| 一区二区三区在线观看网站| 日本不卡视频在线| 色天使久久综合网天天| 精品sm捆绑视频| 一级日本不卡的影视| 经典三级一区二区| 欧美视频一区在线| 亚洲人成电影网站色mp4| 另类小说欧美激情| 欧美少妇xxx| 国产精品国产a| 精品系列免费在线观看| 欧美群妇大交群中文字幕| 国产精品久久夜| 国产精品白丝jk黑袜喷水| 91精品国产高清一区二区三区 | 成人黄色777网| 久久久久国色av免费看影院| 亚洲国产日韩综合久久精品| 丁香婷婷深情五月亚洲| 精品成人在线观看| 五月天视频一区| 欧美在线影院一区二区| 亚洲国产精品av| 蜜桃精品视频在线观看| 欧美专区在线观看一区| 久久久精品免费网站| 精品无码三级在线观看视频| 欧美亚州韩日在线看免费版国语版| 国产精品第一页第二页第三页| 美国一区二区三区在线播放| 欧美亚洲一区三区| 亚洲另类色综合网站| 粉嫩高潮美女一区二区三区| 欧美一区二区三区成人| 国产精品嫩草影院com| 久久国产生活片100| 欧美在线观看视频在线| 国产精品美女视频| 激情小说亚洲一区| 日韩一区二区高清| 免费成人在线播放|