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

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

?? os_sem.c

?? 多任務操作系統uc_OS II移植到keil c51的源代碼
?? 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 *pevent) KCREENTRANT
{
    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) KCREENTRANT
{
    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) KCREENTRANT
{
    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) KCREENTRANT
{
    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) KCREENTRANT
{
    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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
看片的网站亚洲| 色88888久久久久久影院按摩| 国产成人精品影视| 欧美亚洲一区二区在线观看| 国产精品视频一二| 美女精品自拍一二三四| 99精品久久99久久久久| 欧美一区二区视频在线观看| 国产精品久久久久影院| 精品一区二区三区日韩| 欧美日韩中文国产| 亚洲欧美在线另类| 国产精品123区| 精品国产乱码久久久久久夜甘婷婷| 一个色综合网站| 91亚洲国产成人精品一区二区三| 欧美精品一区二区三| 日本不卡一区二区三区| 欧美三级乱人伦电影| 夜夜嗨av一区二区三区网页| 99国内精品久久| 欧美国产日韩a欧美在线观看| 狠狠色狠狠色综合系列| 日韩午夜中文字幕| 日韩和欧美一区二区三区| 在线免费观看日本欧美| 一区二区三区精品| 一本到不卡免费一区二区| 久久精品欧美日韩精品| 国产一区二区网址| 久久久噜噜噜久久人人看 | 91精品国产欧美日韩| 一区二区三区四区在线| 一本久道中文字幕精品亚洲嫩| 亚洲欧美中日韩| 一本大道久久a久久精品综合| 中文字幕五月欧美| 91日韩一区二区三区| 亚洲精品乱码久久久久久日本蜜臀| 波多野结衣中文字幕一区 | 天堂精品中文字幕在线| 欧美美女一区二区| 青青草国产精品97视觉盛宴| 日韩欧美中文一区二区| 美女网站在线免费欧美精品| 欧美精品一区二区在线观看| 国产精品香蕉一区二区三区| 国产精品国产三级国产普通话三级 | 精品国产91洋老外米糕| 国产最新精品精品你懂的| 国产无一区二区| 99热国产精品| 亚洲图片一区二区| 精品欧美一区二区在线观看| 国产xxx精品视频大全| 亚洲麻豆国产自偷在线| 69堂成人精品免费视频| 国精产品一区一区三区mba桃花| 国产农村妇女毛片精品久久麻豆| 91小视频免费看| 亚洲国产精品久久久久秋霞影院| 91麻豆精品国产91久久久更新时间| 狠狠色丁香久久婷婷综合丁香| 国产偷国产偷精品高清尤物| 欧美专区在线观看一区| 蜜桃在线一区二区三区| 国产女人aaa级久久久级| 欧美无砖砖区免费| 国模一区二区三区白浆| 亚洲精品久久7777| 精品国偷自产国产一区| 色婷婷精品大在线视频| 国产一区二区免费在线| 亚洲国产精品欧美一二99| 欧美精品一区二区三区高清aⅴ| 色偷偷一区二区三区| 九九精品视频在线看| 亚洲另类色综合网站| 国产亚洲欧美激情| 欧美区在线观看| 99国产精品一区| 狠狠色丁香久久婷婷综合_中| 一区二区三区在线视频免费 | 欧美一区二区在线不卡| 99国产精品视频免费观看| 麻豆精品国产91久久久久久| 亚洲一区二区三区四区在线| 国产网站一区二区| 日韩丝袜美女视频| 在线日韩一区二区| 成人小视频免费观看| 麻豆国产欧美日韩综合精品二区| 亚洲伦在线观看| 亚洲国产成人在线| 日韩欧美一级精品久久| 欧美日韩一二三区| 91浏览器打开| 成人avav影音| 粉嫩一区二区三区性色av| 久久av资源网| 日本免费在线视频不卡一不卡二| 一级中文字幕一区二区| 国产精品久久网站| 国产亚洲欧美激情| 国产午夜精品一区二区三区四区 | 国产一区二区三区| 久久精品国产澳门| 美女视频黄免费的久久| 日本中文字幕一区二区有限公司| 五月天激情综合| 午夜免费欧美电影| 亚洲电影在线播放| 亚洲妇女屁股眼交7| 亚洲午夜激情网页| 午夜精品久久一牛影视| 亚洲高清免费观看高清完整版在线观看 | 亚洲高清在线视频| 天堂蜜桃一区二区三区| 日韩1区2区日韩1区2区| 另类综合日韩欧美亚洲| 国产美女一区二区| 国产成人综合亚洲91猫咪| 国产麻豆视频一区| 大桥未久av一区二区三区中文| 国产不卡视频一区| 色综合久久久久久久久久久| 色婷婷综合久久久中文一区二区 | 91小宝寻花一区二区三区| 色综合久久中文综合久久97| 欧美在线观看一区| 91精品国产入口| 精品久久久久久久久久久久久久久 | 五月天欧美精品| 久久精品国产77777蜜臀| 国产一区二区免费看| 粉嫩绯色av一区二区在线观看 | 亚洲欧美日韩电影| 五月天亚洲精品| 国产一区在线看| 91久久久免费一区二区| 欧美二区三区的天堂| 久久综合久久99| 综合久久久久久| 日韩中文字幕1| 国产乱码精品一区二区三区忘忧草 | 不卡视频在线看| 日本精品一区二区三区高清| 7777精品伊人久久久大香线蕉完整版 | 欧美激情资源网| 亚洲一区二区高清| 精品一区二区免费看| a级精品国产片在线观看| 欧美日韩视频专区在线播放| 久久人人97超碰com| 亚洲一级在线观看| 国产毛片精品一区| 色综合咪咪久久| 亚洲精品一区在线观看| 亚洲裸体在线观看| 国产精品一级在线| 欧美酷刑日本凌虐凌虐| 国产精品理论在线观看| 老司机免费视频一区二区| 成人aa视频在线观看| 欧美v国产在线一区二区三区| 亚洲色图制服诱惑| 精品一区二区三区香蕉蜜桃| 欧美影视一区在线| 国产精品日日摸夜夜摸av| 麻豆精品国产传媒mv男同 | www久久精品| 亚洲午夜久久久久中文字幕久| 成人午夜av影视| 久久婷婷成人综合色| 婷婷中文字幕综合| 色噜噜偷拍精品综合在线| 久久九九久精品国产免费直播| 天天综合网 天天综合色| www.成人在线| 久久九九久久九九| 狠狠色丁香婷综合久久| 日韩一级成人av| 午夜精品久久久久影视| 色美美综合视频| 亚洲精品亚洲人成人网| 成人国产在线观看| 欧美国产日韩一二三区| 国产v综合v亚洲欧| 久久久精品人体av艺术| 国产一区二区影院| 精品国产乱码久久| 久久99精品国产91久久来源| 777欧美精品| 日日摸夜夜添夜夜添精品视频| 欧美体内she精高潮| 樱花草国产18久久久久| 91福利视频网站| 一区二区三区成人| 欧洲人成人精品| 亚洲国产中文字幕|