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

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

?? os_sem.c

?? ucos在8051F040上的成功移植范例
?? 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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美色综合久久| 精品一区二区三区视频| 亚洲午夜免费电影| 韩国视频一区二区| 欧美三区在线观看| 国产精品国产精品国产专区不蜜 | 欧美老女人第四色| 久久久久久麻豆| 五月天视频一区| 色综合久久久久综合体桃花网| 日韩欧美国产高清| 午夜av一区二区三区| 99精品视频中文字幕| 久久精品人人做人人爽97| 日韩和欧美一区二区| 欧美私模裸体表演在线观看| 国产精品三级久久久久三级| 国产乱人伦偷精品视频不卡| 51精品国自产在线| 亚洲国产精品天堂| 色婷婷一区二区| 国产精品国产自产拍高清av | 99精品视频一区| 国产人久久人人人人爽| 久久成人久久爱| 日韩亚洲欧美在线| 日本美女一区二区| 91超碰这里只有精品国产| 亚洲香蕉伊在人在线观| 色悠悠久久综合| 一区二区三区日韩欧美| 一本高清dvd不卡在线观看 | 久久综合九色综合欧美就去吻| 肉色丝袜一区二区| 日韩欧美国产电影| 国产麻豆成人精品| 中文字幕高清一区| 91在线一区二区三区| 亚洲欧美日韩在线播放| 色狠狠色噜噜噜综合网| 洋洋av久久久久久久一区| 欧美亚洲动漫精品| 亚洲va国产天堂va久久en| 欧美乱熟臀69xxxxxx| 日韩精品欧美成人高清一区二区| 91精品在线免费观看| 久久精品国产精品亚洲红杏| 精品日韩欧美在线| 国产不卡视频一区| 亚洲视频香蕉人妖| 欧美日产在线观看| 精油按摩中文字幕久久| 久久网这里都是精品| www.欧美色图| 亚洲.国产.中文慕字在线| 日韩欧美黄色影院| 成人黄色av网站在线| 亚洲最新视频在线观看| 日韩小视频在线观看专区| 国产黄色精品网站| 亚洲乱码国产乱码精品精的特点| 欧美美女视频在线观看| 极品少妇一区二区| 综合激情成人伊人| 欧美放荡的少妇| 国产精品一区二区无线| 亚洲激情第一区| 精品久久久久久综合日本欧美| 成av人片一区二区| 日日骚欧美日韩| 中文字幕av一区二区三区高| 欧美日韩综合在线| 国产精品91一区二区| 亚洲一区二区黄色| 久久人人97超碰com| 日本精品视频一区二区| 久久99蜜桃精品| 亚洲乱码日产精品bd| 2020日本不卡一区二区视频| 在线亚洲一区观看| 国产精品伊人色| 亚洲午夜免费电影| 中文字幕在线不卡一区| 日韩欧美在线观看一区二区三区| 一本一道久久a久久精品 | 99re在线视频这里只有精品| 日本不卡视频在线观看| 一区二区成人在线| 欧美一区二区三区婷婷月色| 亚洲一区二区美女| 精品国产123| 色婷婷久久综合| 国产成人av影院| 青娱乐精品视频| 亚洲妇女屁股眼交7| 国产精品久久三| 久久亚洲一级片| 日韩色视频在线观看| 在线一区二区三区四区五区 | 91精品国产美女浴室洗澡无遮挡| 91浏览器在线视频| 成人午夜视频在线观看| 激情av综合网| 青草国产精品久久久久久| 亚洲伊人色欲综合网| 中文字幕欧美三区| 日韩一区二区在线播放| 在线中文字幕不卡| 日本韩国一区二区| 91蝌蚪国产九色| 91亚洲午夜精品久久久久久| 成人网在线免费视频| 国产电影一区二区三区| 国产在线观看免费一区| 国产在线精品一区二区不卡了| 秋霞影院一区二区| 免费人成黄页网站在线一区二区 | 亚洲观看高清完整版在线观看 | 午夜欧美一区二区三区在线播放| 亚洲日本护士毛茸茸| 亚洲精品中文在线观看| 一区二区不卡在线视频 午夜欧美不卡在| 中文一区二区完整视频在线观看| 国产亚洲成aⅴ人片在线观看 | 国产福利一区在线| 国产成人精品免费看| 成人av在线电影| 97久久超碰国产精品| 色婷婷精品久久二区二区蜜臂av| 欧美做爰猛烈大尺度电影无法无天| 91久久精品国产91性色tv| 欧美午夜宅男影院| 日韩一区二区三区高清免费看看| 欧美成人一区二区三区片免费| 26uuu另类欧美| 中文字幕一区二区三区蜜月| 艳妇臀荡乳欲伦亚洲一区| 天天色天天操综合| 国内外成人在线视频| 成人国产精品免费观看| 欧美性感一类影片在线播放| 3751色影院一区二区三区| 久久丝袜美腿综合| 亚洲欧美另类小说| 七七婷婷婷婷精品国产| 国产成人在线视频网址| 在线看国产一区| www日韩大片| 亚洲精品综合在线| 经典三级视频一区| 欧美最猛性xxxxx直播| 日韩色在线观看| 1区2区3区欧美| 伦理电影国产精品| 91视频在线观看| 精品国产区一区| 一区二区三区四区精品在线视频| 免费欧美在线视频| 91蜜桃传媒精品久久久一区二区 | 91极品美女在线| 日韩欧美国产三级电影视频| 亚洲欧美日韩久久| 激情成人午夜视频| 欧美美女黄视频| 1024亚洲合集| 久久91精品国产91久久小草| 色综合色狠狠天天综合色| 2014亚洲片线观看视频免费| 亚洲国产wwwccc36天堂| 成人国产精品免费观看| 日韩欧美第一区| 亚洲超碰97人人做人人爱| 成人av免费观看| 精品88久久久久88久久久| 午夜精品久久久久久久99水蜜桃 | 欧美午夜不卡在线观看免费| 中文字幕国产一区二区| 韩国女主播一区| 欧美美女一区二区在线观看| 亚洲乱码国产乱码精品精小说| 国产一区不卡视频| 日韩午夜在线播放| 亚洲高清免费观看| 日本二三区不卡| 亚洲欧美另类综合偷拍| 成人国产精品免费观看动漫| 久久久综合精品| 精品一二线国产| 欧美刺激脚交jootjob| 日韩成人一级大片| 欧美日本免费一区二区三区| 亚洲黄色av一区| 91在线精品秘密一区二区| 国产精品区一区二区三区| 国产福利一区二区三区视频在线| 日韩手机在线导航| 久久99久久久久| 亚洲精品一线二线三线无人区| 日本中文字幕一区| 制服视频三区第一页精品|