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

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

?? os_sem.c

?? 在MC68HC908JB8上移植UCOSII成功
?? 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
*********************************************************************************************************
*/


#include "includes.h"


#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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99国产精品一区| 99久久久精品| 亚洲一区二区三区视频在线播放 | 欧美日韩精品一区二区天天拍小说 | 亚洲一区二区综合| 国产精品狼人久久影院观看方式| 久久综合九色综合欧美就去吻| 欧美一区二区日韩一区二区| 6080日韩午夜伦伦午夜伦| 在线成人av网站| 日韩欧美中文字幕精品| 日韩精品一区二区三区中文不卡 | 99国产精品久久久久久久久久| 成人福利视频网站| 99久久婷婷国产综合精品| 99视频在线精品| 色悠久久久久综合欧美99| 91美女福利视频| 在线观看网站黄不卡| 欧美日韩综合在线| 91精品婷婷国产综合久久竹菊| 国产午夜精品久久久久久久| 精品国产一区二区三区av性色| 日韩欧美区一区二| 精品福利在线导航| 国产欧美日韩中文久久| 亚洲九九爱视频| 亚洲成人你懂的| 男女性色大片免费观看一区二区 | 国产成人高清在线| 成人一区二区三区视频在线观看 | 色婷婷精品久久二区二区蜜臀av | 99re这里都是精品| 欧美撒尿777hd撒尿| 日韩午夜三级在线| 久久久国际精品| 亚洲柠檬福利资源导航| 91精品久久久久久久久99蜜臂| 日本一区二区三区电影| 国产精品私人自拍| 亚洲一区二区视频| 久久精品久久综合| av不卡在线播放| 91精品国模一区二区三区| 久久这里只有精品首页| 一区在线播放视频| 热久久国产精品| eeuss国产一区二区三区| 欧美伦理影视网| 国产欧美日韩在线看| 亚洲 欧美综合在线网络| 精品一区精品二区高清| 99久久国产综合精品色伊 | 国产精品高潮久久久久无| 亚洲大型综合色站| 国产99精品国产| 欧美精三区欧美精三区| 欧美韩国日本一区| 日韩av一二三| 91麻豆精品视频| 欧美精品一区二区久久久| 一区av在线播放| 亚洲一区二区av电影| 日韩高清中文字幕一区| 国产成人免费av在线| 欧美日韩电影在线| 国产精品你懂的在线| 免费成人在线观看视频| 色婷婷一区二区三区四区| 精品久久久久久久久久久久包黑料| 亚洲人一二三区| 岛国精品在线观看| 精品国产麻豆免费人成网站| 亚洲夂夂婷婷色拍ww47| 成人一区二区三区| 久久中文字幕电影| 日本亚洲免费观看| 欧美主播一区二区三区| 亚洲欧洲色图综合| 国产美女精品人人做人人爽| 欧美一区二区三区男人的天堂| 亚洲精品国产a| av欧美精品.com| 欧美激情一区在线观看| 国产在线精品一区二区不卡了| 欧美美女黄视频| 亚洲高清中文字幕| 在线观看免费亚洲| 亚洲视频 欧洲视频| 成人黄色777网| 国产亚洲一区字幕| 狠狠v欧美v日韩v亚洲ⅴ| 成人午夜私人影院| 亚洲高清免费一级二级三级| 国产福利一区二区| 精品处破学生在线二十三| 视频一区在线播放| 7777精品伊人久久久大香线蕉| 一区二区三区久久| 色婷婷国产精品| 亚洲人成网站精品片在线观看| av在线不卡免费看| 日韩一区有码在线| 99热99精品| 亚洲三级久久久| 色婷婷一区二区| 亚洲午夜激情av| 欧美视频在线观看一区| 午夜欧美视频在线观看| 欧美一区二区精品| 美女视频黄频大全不卡视频在线播放| 777xxx欧美| 美女高潮久久久| 久久综合给合久久狠狠狠97色69| 国产另类ts人妖一区二区| 久久久精品免费免费| 丁香五精品蜜臀久久久久99网站 | 中文字幕一区二区三区精华液| 国产91高潮流白浆在线麻豆| 国产精品国模大尺度视频| 不卡视频免费播放| 亚洲精品福利视频网站| 欧美二区三区91| 久久超碰97中文字幕| 国产视频一区二区三区在线观看| gogo大胆日本视频一区| 一区二区久久久| 欧美一区二区三区在线| 国产精品正在播放| 日韩美女精品在线| 欧美久久久影院| 国产一区二区三区在线观看免费视频| 国产欧美一区二区精品久导航 | 2020国产精品久久精品美国| 国产成人99久久亚洲综合精品| 中文字幕日本不卡| 欧美日韩国产免费一区二区| 九九精品一区二区| 亚洲欧美中日韩| 91精品国产手机| 成人在线视频一区二区| 亚洲成人综合网站| 久久久天堂av| 在线观看国产日韩| 国产一区二区不卡| 亚洲最新在线观看| 欧美精品一区二区三区蜜桃视频 | 久久精品在线观看| 色狠狠色狠狠综合| 久久99精品国产麻豆不卡| 亚洲欧美中日韩| 精品日韩一区二区三区免费视频| 91日韩精品一区| 免费一级片91| 亚洲四区在线观看| 欧美不卡在线视频| 色一情一乱一乱一91av| 黑人精品欧美一区二区蜜桃| 一区二区视频在线看| 欧美精品一区二区蜜臀亚洲| 色综合久久久久| 国产九色sp调教91| 视频一区欧美日韩| 亚洲视频一区二区在线观看| 久久青草欧美一区二区三区| 欧美猛男超大videosgay| eeuss国产一区二区三区| 国内精品伊人久久久久影院对白| 亚洲亚洲精品在线观看| 国产精品丝袜一区| 精品免费日韩av| 欧美老人xxxx18| 91视频观看免费| 国产乱码精品1区2区3区| 奇米色一区二区| 亚洲一区视频在线| 国产精品乱码久久久久久| 欧美大肚乱孕交hd孕妇| 欧美日韩黄视频| 色偷偷一区二区三区| 成人黄色小视频| 国产高清精品在线| 国产在线播放一区二区三区| 99麻豆久久久国产精品免费 | 精品少妇一区二区三区在线播放| 91精彩视频在线观看| 国产高清精品网站| 狠狠色狠狠色合久久伊人| 视频在线观看一区| 亚洲国产wwwccc36天堂| 伊人色综合久久天天人手人婷| 中文字幕一区二区三区不卡在线| 久久精品视频一区二区三区| 日韩精品自拍偷拍| 91精品国产91久久久久久最新毛片| 在线看不卡av| 色先锋资源久久综合| 色综合色综合色综合| 成人精品鲁一区一区二区| 国产成人免费在线|