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

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

?? os_sem.c

?? 這是完整的ucos在51上移植的資料
?? 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) 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

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区视频在线观看2020 | 日韩欧美国产一二三区| 成人av资源在线观看| 久久精品国产亚洲一区二区三区| 亚洲地区一二三色| 亚洲成在线观看| 日日夜夜免费精品| 青青草视频一区| 久久99在线观看| 国产一区二区三区精品视频| 国产一区91精品张津瑜| 国产乱人伦偷精品视频不卡| 国产成人综合在线观看| 国产成人亚洲综合色影视| 国产99久久久国产精品| 9人人澡人人爽人人精品| 99久久精品国产观看| 色综合色狠狠综合色| 欧美视频在线一区| 欧美一区二区三区免费视频| 精品国产乱码久久久久久免费| 久久嫩草精品久久久精品一| 国产欧美视频一区二区三区| 综合久久久久久久| 亚洲v中文字幕| 狠狠色丁香久久婷婷综| fc2成人免费人成在线观看播放| 一本色道久久综合亚洲91| 欧美另类videos死尸| 精品国产一区久久| 亚洲精品视频观看| 乱中年女人伦av一区二区| 国产69精品久久久久777| 欧美午夜一区二区三区| 精品精品欲导航| 亚洲精品福利视频网站| 久久97超碰色| 欧美中文字幕不卡| 久久这里只有精品首页| 一级特黄大欧美久久久| 国产在线国偷精品产拍免费yy| 91农村精品一区二区在线| 欧美一区二区三级| 亚洲欧美激情一区二区| 狠狠色丁香婷婷综合| 欧美色老头old∨ideo| 久久久另类综合| 午夜精品免费在线观看| 成人一区二区三区| 欧美成人精品3d动漫h| 亚洲一区国产视频| 成人激情免费视频| 久久丝袜美腿综合| 青青草一区二区三区| 在线免费一区三区| 国产欧美一区二区精品性色| 日本在线不卡视频| 在线看国产日韩| 亚洲欧洲性图库| 国产一区二区伦理片| 欧美一区二区久久| 天堂久久一区二区三区| 91成人免费在线| 亚洲人123区| 暴力调教一区二区三区| 国产人久久人人人人爽| 狠狠色综合日日| 精品人在线二区三区| 丝袜亚洲另类丝袜在线| 欧美日韩在线不卡| 夜夜嗨av一区二区三区网页| 91视频.com| ...xxx性欧美| 91在线播放网址| 日韩一区欧美一区| 色综合视频一区二区三区高清| 国产亚洲一区二区三区在线观看| 国内精品久久久久影院色| 日韩女优制服丝袜电影| 久草在线在线精品观看| 久久影院午夜论| 国产91高潮流白浆在线麻豆| 久久久国产午夜精品| 高清不卡一区二区| 国产精品成人一区二区艾草| 91在线丨porny丨国产| 亚洲欧美欧美一区二区三区| 日本道免费精品一区二区三区| 亚洲精品少妇30p| 精品裸体舞一区二区三区| 国产真实乱对白精彩久久| 国产欧美日本一区二区三区| 成人精品一区二区三区中文字幕| 国产精品久久夜| 在线视频国产一区| 日韩高清在线电影| 久久色在线视频| 91香蕉国产在线观看软件| 亚洲在线观看免费视频| 日韩一区二区三区av| 国产一区在线精品| 亚洲精品中文字幕乱码三区| 欧美视频精品在线观看| 免费不卡在线视频| 欧美高清在线一区二区| 色久优优欧美色久优优| 日本成人在线不卡视频| 欧美激情在线一区二区| 在线精品观看国产| 精品一二三四区| 亚洲狼人国产精品| 精品国精品自拍自在线| 在线观看日韩电影| 国产电影一区在线| 午夜精品一区二区三区免费视频 | 日韩手机在线导航| 99精品在线观看视频| 奇米精品一区二区三区在线观看 | 欧美一区二区在线不卡| 国产91精品在线观看| 偷窥少妇高潮呻吟av久久免费| 久久久国产精品不卡| 欧美日韩一区二区三区四区 | 一片黄亚洲嫩模| 久久久久亚洲蜜桃| 在线不卡的av| 91丨九色porny丨蝌蚪| 国产在线播精品第三| 亚洲无人区一区| 国产精品久久久一区麻豆最新章节| 欧美一二三在线| 欧美午夜精品久久久久久超碰| 国产福利一区二区三区在线视频| 亚洲国产婷婷综合在线精品| 国产精品你懂的在线| 久久综合一区二区| 日韩欧美黄色影院| 欧美日韩国产天堂| 91高清视频在线| 99精品视频在线观看| 国产夫妻精品视频| 九九九精品视频| 日本欧美韩国一区三区| 亚洲一区二区三区四区在线| 亚洲视频在线一区二区| 国产精品少妇自拍| 国产午夜精品一区二区三区嫩草| 日韩欧美国产综合一区| 欧美一区二区三区精品| 91精品国产91久久综合桃花| 欧洲精品在线观看| 欧美亚洲日本国产| 欧美中文字幕久久| 欧美精三区欧美精三区| 欧美日韩免费在线视频| 欧美在线观看一区| 欧美视频一二三区| 欧美二区三区的天堂| 欧美一区二区视频在线观看2022| 欧美日韩大陆一区二区| 欧美一区二区三区日韩视频| 日韩午夜激情免费电影| 精品国产一区二区三区久久久蜜月 | 色欧美88888久久久久久影院| 白白色亚洲国产精品| voyeur盗摄精品| 91一区一区三区| 欧洲色大大久久| 欧美一区二区三区喷汁尤物| 日韩色在线观看| 久久精品亚洲乱码伦伦中文| 欧美高清在线一区二区| 一区二区在线观看视频 | 久久国产欧美日韩精品| 精东粉嫩av免费一区二区三区| 国产一区日韩二区欧美三区| 国产白丝精品91爽爽久久| 91一区二区在线| 4438x成人网最大色成网站| 久久久久久久久岛国免费| 国产精品初高中害羞小美女文| 亚洲乱码日产精品bd | 久久综合九色综合97婷婷女人| 国产女同互慰高潮91漫画| 亚洲精品你懂的| 美女视频网站黄色亚洲| 成人在线综合网| 欧美日韩第一区日日骚| 国产亚洲一二三区| 午夜电影一区二区三区| 国产酒店精品激情| 欧美日韩在线播放三区| 久久综合久久99| 一区二区三区在线观看网站| 蜜臀av在线播放一区二区三区| 粉嫩欧美一区二区三区高清影视| 欧美中文字幕不卡| 中文字幕乱码一区二区免费| 香港成人在线视频| 91丨九色丨蝌蚪丨老版|