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

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

?? os_sem.c

?? UCOS-II移植C8051單片機(jī)上 使用C8051F020開發(fā)板。KEIL U3編譯通過。 串口連接到PC機(jī)上
?? 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) 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 *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);
}

/*$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) 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;
        }
    }
}
/*$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) 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);
        }
    }
}
/*
*********************************************************************************************************
*                                          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 *ppdata) 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);
    }
    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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人免费视频精品含羞草妖精| 在线视频你懂得一区二区三区| 日韩高清一区二区| 亚洲123区在线观看| 亚洲自拍另类综合| 亚洲成人免费观看| 香蕉影视欧美成人| 日本不卡高清视频| 免费观看91视频大全| 美女视频黄免费的久久| 久久99精品久久久| 国产美女精品在线| 粉嫩av亚洲一区二区图片| 国产91清纯白嫩初高中在线观看| 成人中文字幕在线| 91美女片黄在线| 欧美日韩高清一区二区三区| 7777精品伊人久久久大香线蕉经典版下载| 欧美日韩一二三区| 日韩欧美国产一区在线观看| 精品国产一区二区在线观看| 国产亚洲人成网站| 国产精品久久国产精麻豆99网站| 亚洲色图视频免费播放| 一区二区三区日韩在线观看| 亚洲成在线观看| 老司机午夜精品| 从欧美一区二区三区| 91免费精品国自产拍在线不卡| 欧美日韩日本视频| 久久一二三国产| 日韩理论片在线| 丝瓜av网站精品一区二区 | 国产一区二区三区精品欧美日韩一区二区三区| 九色综合狠狠综合久久| www.亚洲色图| 欧美日韩一区成人| 国产午夜亚洲精品理论片色戒| 亚洲天堂福利av| 日本免费新一区视频| 国产不卡高清在线观看视频| 欧美视频一区二区三区四区| 日韩欧美电影在线| 日韩美女啊v在线免费观看| 日本色综合中文字幕| www.激情成人| 欧美一区二区精品久久911| 国产精品人成在线观看免费| 亚洲成人在线观看视频| 粉嫩一区二区三区在线看| 欧美午夜精品久久久久久孕妇| 久久亚洲综合色| 亚洲影视在线播放| 国产精品99久久久久久久vr| 欧美亚洲另类激情小说| 国产性天天综合网| 五月激情综合网| www.日韩大片| 欧美大黄免费观看| 亚洲自拍偷拍网站| 成人av午夜电影| 日韩欧美国产一区在线观看| 一区二区三区免费看视频| 国产精品18久久久| 日韩片之四级片| 亚洲一区二区三区美女| 国产99久久久久久免费看农村| 6080亚洲精品一区二区| 亚洲欧美国产三级| 国产精品香蕉一区二区三区| 日韩一区二区三区在线| 亚洲精品国产一区二区精华液| 国产福利一区在线| 日韩欧美激情一区| 图片区日韩欧美亚洲| 成人精品一区二区三区四区| 精品日韩欧美在线| 天天综合色天天综合色h| 色综合久久天天| 中文一区二区在线观看| 久久国产精品99久久久久久老狼 | 久久综合色一综合色88| 五月天一区二区| 欧美日韩一二三区| 亚洲精品成人在线| 91在线观看免费视频| 国产精品久久久爽爽爽麻豆色哟哟 | 中文字幕视频一区二区三区久| 韩国av一区二区三区在线观看| 777午夜精品免费视频| 亚洲成av人**亚洲成av**| 一本到三区不卡视频| 亚洲欧洲精品成人久久奇米网| 丁香激情综合五月| 日本一区二区久久| 国产91精品久久久久久久网曝门| 久久久久久久综合| 国产乱码字幕精品高清av| 欧美xxxx老人做受| 久久国内精品自在自线400部| 日韩一区二区三区视频| 奇米色一区二区| 91精品国产aⅴ一区二区| 日本v片在线高清不卡在线观看| 欧美高清激情brazzers| 水蜜桃久久夜色精品一区的特点 | 日本一区二区视频在线观看| 国产精品一区二区在线看| 久久精品视频一区二区三区| 国产一本一道久久香蕉| 欧美国产日韩精品免费观看| 国产69精品久久99不卡| 国产精品日韩成人| 91蜜桃传媒精品久久久一区二区| 一区二区三区久久久| 欧美日韩电影在线| 日本91福利区| 久久亚洲一区二区三区明星换脸| 国产传媒一区在线| 中文字幕在线观看不卡| 91久久奴性调教| 日韩不卡手机在线v区| 精品剧情v国产在线观看在线| 国产一区欧美日韩| 国产精品国产三级国产| 色婷婷激情综合| 日韩电影一区二区三区| 精品国产1区二区| 成人性色生活片| 亚洲尤物视频在线| 欧美成人性战久久| 成人爱爱电影网址| 亚洲综合色丁香婷婷六月图片| 在线电影一区二区三区| 国产一区二三区| 亚洲色图在线视频| 日韩一区二区在线免费观看| 国产精品一区二区在线观看不卡| 亚洲女同女同女同女同女同69| 欧美日韩免费在线视频| 国产综合色精品一区二区三区| 国产精品久久久久久久久图文区| 欧美在线播放高清精品| 紧缚奴在线一区二区三区| 最好看的中文字幕久久| 日韩三级在线观看| 99精品视频一区| 日韩高清不卡在线| 国产精品国产自产拍高清av| 欧美顶级少妇做爰| 成人性生交大片| 蜜臀av一级做a爰片久久| 国产精品灌醉下药二区| 欧美一区二区三区日韩视频| 成人综合在线观看| 免费观看在线色综合| 亚洲三级久久久| 久久综合九色综合久久久精品综合 | 99久久精品免费精品国产| 日韩二区在线观看| 亚洲人精品午夜| 久久亚洲综合色一区二区三区 | 国产精品久久久久久户外露出 | 欧美午夜精品久久久| 国产精品自产自拍| 天天做天天摸天天爽国产一区| 国产精品美女久久久久久久网站| 7777精品伊人久久久大香线蕉| 91在线观看一区二区| 韩国女主播一区| 日韩主播视频在线| 亚洲欧美成人一区二区三区| 久久精品一区二区三区不卡牛牛| 制服丝袜亚洲色图| 在线视频欧美精品| www.色综合.com| 国产成人精品一区二| 美女网站色91| 亚洲成人黄色影院| 亚洲欧美激情插 | 久久成人久久鬼色| 亚洲小说春色综合另类电影| 中文字幕一区在线观看| 久久久久国产精品人| 日韩一本二本av| 欧美猛男超大videosgay| 91免费观看国产| 99在线精品免费| 国产成人av资源| 国内精品久久久久影院一蜜桃| 美女视频一区在线观看| 午夜亚洲福利老司机| 一区二区在线观看不卡| 亚洲欧美自拍偷拍| 日本一区二区综合亚洲| 国产欧美日韩在线| 国产日韩欧美a| 久久久久青草大香线综合精品| 欧美va在线播放| 欧美成人精品福利|