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

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

?? os_sem.c

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕欧美区| 91麻豆国产精品久久| 日韩欧美亚洲国产精品字幕久久久| 一区二区三区日韩| 欧美亚洲国产怡红院影院| 亚洲影视在线观看| 91精品国产手机| 久久99国产精品成人| 国产视频一区二区在线观看| 成人综合婷婷国产精品久久免费| 国产精品家庭影院| 日本高清不卡一区| 免费av成人在线| 久久精品夜色噜噜亚洲a∨| 99精品视频中文字幕| 7777精品伊人久久久大香线蕉经典版下载 | 日本午夜一本久久久综合| 一区二区在线免费观看| 午夜av区久久| 一区二区三区四区国产精品| 亚洲18色成人| 精品一区二区三区久久| 国产亚洲一区二区三区四区| 日韩亚洲欧美中文三级| 欧美一区二区久久| 国产亚洲欧美日韩在线一区| 日韩毛片高清在线播放| 国产精品中文有码| 欧美精品电影在线播放| 国产日产精品1区| 日本大胆欧美人术艺术动态| 蜜桃视频第一区免费观看| 高清在线观看日韩| 欧美电影免费观看高清完整版在线观看| 亚洲国产另类av| 亚洲国产精品成人综合| 在线观看免费视频综合| 欧美日韩成人高清| 成人免费毛片片v| 午夜精品一区二区三区电影天堂| 久久久久国色av免费看影院| 欧美日韩国产另类一区| www.欧美日韩国产在线| 日韩黄色一级片| 亚洲精品写真福利| 久久久久久久电影| 欧美精品vⅰdeose4hd| 波多野结衣一区二区三区| 免费在线观看不卡| 一区二区三区视频在线看| 久久精品在线免费观看| 欧美二区在线观看| 91精品办公室少妇高潮对白| 国产精品小仙女| 免费在线观看日韩欧美| 亚洲国产精品久久一线不卡| 综合久久综合久久| 欧美国产日本韩| 久久婷婷一区二区三区| 欧美一区二区在线看| 欧美日韩亚洲不卡| 在线亚洲高清视频| 91视视频在线观看入口直接观看www| 国产精品原创巨作av| 一本大道综合伊人精品热热| 国产永久精品大片wwwapp | 国产成人在线视频免费播放| 免费在线视频一区| 日韩av一级电影| 亚洲大尺度视频在线观看| 亚洲美女淫视频| 亚洲欧美精品午睡沙发| 亚洲私人黄色宅男| 国产精品久久久久久久久免费桃花| 久久久99精品免费观看不卡| 久久欧美一区二区| 久久久久久久久久久久久久久99| 欧美成人a∨高清免费观看| 欧美变态凌虐bdsm| 精品国产免费人成电影在线观看四季| 日韩欧美视频一区| 精品美女被调教视频大全网站| 欧美tk丨vk视频| 久久综合狠狠综合| 中文字幕av资源一区| 国产精品美女视频| 亚洲人成伊人成综合网小说| 一区二区三区**美女毛片| 亚洲福利国产精品| 日韩va欧美va亚洲va久久| 蜜桃视频一区二区三区| 国产美女一区二区三区| 国产不卡视频一区| 色综合天天综合网国产成人综合天 | 国产精品久久久久久一区二区三区| 国产精品美女久久久久高潮| 中文字幕精品—区二区四季| 国产精品久久久99| 亚洲美女偷拍久久| 日日夜夜一区二区| 国内精品自线一区二区三区视频| 国产成人精品www牛牛影视| 99精品国产热久久91蜜凸| 欧美日韩在线播放一区| 日韩欧美国产1| 国产精品久线在线观看| 亚洲一区二区3| 成人avav影音| 欧美老女人第四色| 久久噜噜亚洲综合| 一区二区在线观看av| 视频一区二区三区入口| 捆绑调教美女网站视频一区| 成人久久18免费网站麻豆| 欧美日韩成人在线| 亚洲国产精品ⅴa在线观看| 亚洲欧美日韩久久精品| 裸体歌舞表演一区二区| 成人高清av在线| 91精品国产综合久久精品性色| 香蕉加勒比综合久久| 午夜视频一区二区| 国产在线视视频有精品| 色婷婷一区二区三区四区| 日韩免费电影网站| 中文字幕亚洲一区二区va在线| 亚洲精品免费视频| 精品一区二区三区的国产在线播放| 国产福利一区二区| 欧美嫩在线观看| 1区2区3区精品视频| 国模一区二区三区白浆| 99久久国产综合色|国产精品| 精品日韩在线观看| 一区二区三区中文字幕精品精品 | 性欧美疯狂xxxxbbbb| 国产精品77777竹菊影视小说| 国产精品嫩草99a| 色综合天天天天做夜夜夜夜做| 26uuu精品一区二区在线观看| 亚洲国产精品久久久久秋霞影院| 五月婷婷久久综合| 久久精品国产色蜜蜜麻豆| 欧美老年两性高潮| 亚洲一区在线视频观看| 国产精品视频观看| 亚洲男人都懂的| 捆绑调教一区二区三区| 成人精品视频网站| 欧美精品一区二区三区四区| 日韩高清国产一区在线| 在线观看视频一区二区欧美日韩| 中文字幕欧美日本乱码一线二线| 久久黄色级2电影| 日韩午夜激情视频| 美女视频一区在线观看| 欧美丰满高潮xxxx喷水动漫| 亚洲成人动漫在线观看| 在线视频综合导航| 一区二区三区精品在线| 一本色道久久综合亚洲aⅴ蜜桃| 国产精品日韩精品欧美在线| 粉嫩绯色av一区二区在线观看| www日韩大片| 国产美女在线精品| 国产日韩欧美一区二区三区综合| 国内外成人在线视频| 久久亚洲精华国产精华液| 久久精品国产精品亚洲精品| 日韩欧美国产一区在线观看| 久久国产免费看| 欧美刺激午夜性久久久久久久| 麻豆91在线播放| 久久久久久夜精品精品免费| 精品一区二区三区视频在线观看| 精品久久国产97色综合| 国产高清不卡一区| 国产精品入口麻豆原神| 99久久99久久综合| 亚洲资源中文字幕| 欧美精品视频www在线观看| 日本欧美大码aⅴ在线播放| 日韩一区二区三区电影在线观看| 蜜桃在线一区二区三区| 欧美zozozo| 成人白浆超碰人人人人| 亚洲日本在线观看| 欧美日韩国产精品自在自线| 国产精品一区二区在线看| 国产精品午夜在线| 欧洲生活片亚洲生活在线观看| 亚洲mv大片欧洲mv大片精品| 欧美成人精精品一区二区频| 国产.精品.日韩.另类.中文.在线.播放| 亚洲国产成人一区二区三区| 色播五月激情综合网| 九色|91porny| 成人欧美一区二区三区视频网页| 欧美午夜精品一区二区三区| 九一久久久久久|