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

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

?? os_sem.c

?? ucos-ii-at90S-icc-avr
?? 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 *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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产中文字幕在线视频综合| 国产精品一二三四| 亚洲国产精品传媒在线观看| 色综合久久久久综合体桃花网| 首页综合国产亚洲丝袜| 国产精品视频一区二区三区不卡| 欧美日韩中文一区| 99re66热这里只有精品3直播| 免费欧美在线视频| 亚洲午夜av在线| 国产精品拍天天在线| 精品久久久久久无| 欧美日韩一区二区欧美激情| 99re热这里只有精品免费视频| 欧美日韩成人激情| 成人a区在线观看| 精品一区二区久久久| 天堂va蜜桃一区二区三区漫画版| 中文字幕亚洲在| 国产日韩精品久久久| 精品美女在线播放| 91精品国产手机| 在线视频综合导航| 色网站国产精品| www.99精品| 成人免费视频免费观看| 韩国一区二区三区| 老色鬼精品视频在线观看播放| 亚洲成年人网站在线观看| 亚洲裸体xxx| 亚洲天堂中文字幕| 中文字幕一区二区三区乱码在线| 久久久夜色精品亚洲| 精品日产卡一卡二卡麻豆| 欧美精品在线视频| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 蜜臀久久久久久久| 亚洲国产欧美日韩另类综合| 亚洲摸摸操操av| 国产精品成人在线观看| 中文一区一区三区高中清不卡| 亚洲精品一区二区三区福利 | 国产福利一区在线观看| 国内精品写真在线观看| 久久99国产精品久久| 免费在线看一区| 麻豆久久久久久| 黄页视频在线91| 国产成人免费视频网站高清观看视频 | 久久丝袜美腿综合| 久久这里只有精品视频网| 久久亚洲影视婷婷| 欧美激情一区在线观看| 国产精品美女久久久久aⅴ| 国产精品看片你懂得| 中文字幕一区二区三区蜜月| 亚洲精品高清在线观看| 亚洲电影视频在线| 日本不卡中文字幕| 国内精品国产三级国产a久久| 激情文学综合插| 成人午夜激情在线| 色欧美日韩亚洲| 91精品中文字幕一区二区三区| 日韩欧美成人午夜| 国产日韩一级二级三级| 亚洲色图欧美偷拍| 日韩高清欧美激情| 国产麻豆视频一区二区| 91亚洲午夜精品久久久久久| 欧美日韩日日骚| 天天综合日日夜夜精品| 寂寞少妇一区二区三区| 99久久综合狠狠综合久久| 欧美三级日韩三级| 精品国产一区二区精华 | 午夜精品福利在线| 激情欧美一区二区| 一本大道久久a久久精二百| 91精品久久久久久久99蜜桃| 国产日韩成人精品| 亚洲国产成人91porn| 国产伦精品一区二区三区视频青涩 | 欧美日韩午夜精品| xfplay精品久久| 亚洲精品videosex极品| 美腿丝袜亚洲三区| 91一区二区在线| 欧美一激情一区二区三区| 中文字幕不卡在线播放| 日韩精品一级二级| 波多野结衣中文字幕一区二区三区| 欧美三级电影在线观看| 久久精品亚洲国产奇米99| 亚洲国产一区二区视频| 粉嫩绯色av一区二区在线观看| 欧美综合一区二区三区| 国产日本一区二区| 男人操女人的视频在线观看欧美 | 91精品免费观看| 国产精品传媒视频| 九九热在线视频观看这里只有精品| 不卡视频在线观看| 日韩精品一区二区三区蜜臀| 亚洲视频你懂的| 国产乱码字幕精品高清av | 日韩美一区二区三区| 亚洲三级在线免费观看| 精品一区二区在线观看| 欧美性猛交一区二区三区精品| 久久精品视频免费观看| 美女网站在线免费欧美精品| 欧美亚洲国产bt| 亚洲视频小说图片| 粉嫩av一区二区三区| 久久亚洲春色中文字幕久久久| 天天综合色天天| 欧美亚洲免费在线一区| ●精品国产综合乱码久久久久| 国产精品69久久久久水密桃| 欧美一区永久视频免费观看| 亚洲国产一二三| 在线日韩国产精品| 蜜桃精品视频在线| 91精品综合久久久久久| 亚洲国产成人高清精品| 欧美主播一区二区三区美女| 国产精品国产三级国产普通话蜜臀 | 麻豆精品视频在线观看免费| 欧美亚一区二区| 亚洲综合免费观看高清完整版在线| 成人福利在线看| 中文字幕av在线一区二区三区| 国产精品一色哟哟哟| 久久先锋资源网| 国产一区二区按摩在线观看| 精品国产99国产精品| 精品综合久久久久久8888| 日韩欧美卡一卡二| 久久不见久久见免费视频7| 日韩视频国产视频| 精品一区二区三区在线播放 | 久久久久国产精品麻豆| 国产一区欧美日韩| 久久久久久久久久久久久久久99 | 成人激情图片网| 中文字幕一区二| 一本到不卡免费一区二区| 亚洲男帅同性gay1069| 91一区一区三区| 亚洲最新视频在线观看| 欧洲一区在线观看| 日韩高清在线观看| 日韩欧美黄色影院| 高清成人在线观看| 最新国产精品久久精品| 91九色02白丝porn| 日韩国产欧美在线观看| 日韩一区二区在线观看| 久久av资源网| 国产精品久久久久久久久动漫| 一本色道a无线码一区v| 亚洲成a人片综合在线| 日韩午夜小视频| 国产不卡高清在线观看视频| 最新日韩av在线| 欧美乱熟臀69xxxxxx| 精品一区二区三区在线播放视频| 国产人成亚洲第一网站在线播放| 99精品一区二区| 午夜精品福利视频网站| 精品国产青草久久久久福利| 懂色一区二区三区免费观看| 亚洲一区影音先锋| 欧美成人性战久久| 91免费看片在线观看| 日韩综合在线视频| 国产喷白浆一区二区三区| 91国偷自产一区二区三区成为亚洲经典| 亚洲高清一区二区三区| 久久精品人人做人人爽97| 在线观看视频一区二区欧美日韩| 麻豆一区二区三区| 最近中文字幕一区二区三区| 在线成人小视频| 成人a免费在线看| 秋霞成人午夜伦在线观看| 中文字幕一区av| 欧美电影免费观看高清完整版在线| 白白色亚洲国产精品| 琪琪久久久久日韩精品| 亚洲人吸女人奶水| 久久女同精品一区二区| 欧美色视频在线| 成人少妇影院yyyy| 六月婷婷色综合| 亚洲高清一区二区三区| 国产精品欧美一级免费| 日韩三级免费观看| 欧美亚洲综合网|