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

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

?? os_sem.c

?? 在Keil C環(huán)境下運行的uCOS-
?? 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一区二区三区免费野_久草精品视频
精品国精品自拍自在线| 午夜国产不卡在线观看视频| 欧美精品一区二区三区蜜桃| 欧美一区二区三区四区高清| 欧美日韩在线综合| 欧美人狂配大交3d怪物一区| 欧美日韩国产高清一区二区三区| 日本乱人伦aⅴ精品| 欧美专区日韩专区| 欧美午夜在线一二页| 欧美日韩一区二区三区在线| 色吧成人激情小说| 在线成人av网站| 日韩一区二区影院| 精品久久久久99| 精品999久久久| 国产欧美视频一区二区三区| 国产欧美一区二区在线观看| 国产精品成人在线观看| 亚洲精品国产一区二区三区四区在线 | 欧美一区二区视频观看视频| 欧美一级二级三级乱码| 日韩一二在线观看| 精品粉嫩超白一线天av| 国产日韩亚洲欧美综合| 亚洲色欲色欲www| 亚洲图片欧美色图| 久久国产精品一区二区| 精品一区二区在线观看| 国产a级毛片一区| 色婷婷综合在线| 欧美电影一区二区三区| 久久精品无码一区二区三区| 中文天堂在线一区| 亚洲成av人片www| 国产精品系列在线播放| 91国内精品野花午夜精品| 9191久久久久久久久久久| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品久久一级| 午夜a成v人精品| 国产91丝袜在线18| 欧美性猛片xxxx免费看久爱| 日韩小视频在线观看专区| 欧美激情在线观看视频免费| 亚洲自拍偷拍综合| 黑人巨大精品欧美一区| 色视频一区二区| 久久综合色鬼综合色| 亚洲乱码国产乱码精品精的特点| 日韩av一区二区三区| 韩国理伦片一区二区三区在线播放| 国产一区二区三区四区五区美女| 97久久超碰精品国产| 日韩你懂的在线观看| 一区二区三区四区不卡视频| 精品一区二区三区免费播放| 一道本成人在线| 国产亚洲综合性久久久影院| 亚洲夂夂婷婷色拍ww47 | 成人av集中营| 欧美久久久久久久久| 久久麻豆一区二区| 亚洲国产你懂的| 成人久久视频在线观看| 欧美一区午夜精品| 亚洲黄色免费电影| 国产成人免费9x9x人网站视频| 欧美日本国产视频| 国产精品久久久久婷婷| 精品一二三四在线| 欧美人狂配大交3d怪物一区| 亚洲少妇屁股交4| 岛国精品在线观看| 日韩欧美国产电影| 亚洲国产三级在线| 一本到高清视频免费精品| 久久久久综合网| 美女国产一区二区三区| 欧美亚洲综合色| 亚洲人一二三区| 国产福利一区二区三区视频| 欧美大度的电影原声| 午夜精品久久久久影视| 色天天综合久久久久综合片| 国产精品免费av| 国产99久久久精品| 国产婷婷色一区二区三区四区| 蜜臀av性久久久久蜜臀av麻豆| 欧美丝袜丝交足nylons图片| 亚洲色图在线播放| 99久久精品国产毛片| 中文字幕成人在线观看| 国产不卡免费视频| 欧美激情一区三区| 国产精品综合一区二区三区| 亚洲精品在线观看网站| 美女诱惑一区二区| 精品免费日韩av| 精品一区二区国语对白| 一区二区三区在线免费视频 | 麻豆久久久久久| 91精品国产免费久久综合| 亚洲激情校园春色| 色吧成人激情小说| 亚洲成av人片在线| 欧美一区欧美二区| www国产亚洲精品久久麻豆| 欧美精品久久久久久久多人混战 | 国产精品中文字幕欧美| 日韩欧美高清一区| 美国三级日本三级久久99| 欧美日韩高清一区二区| 亚洲成av人片www| 91麻豆精品国产91久久久使用方法| 午夜精品久久久久久久久| 欧美麻豆精品久久久久久| 五月天视频一区| 精品欧美一区二区三区精品久久 | 成人99免费视频| 亚洲免费在线电影| 欧美中文一区二区三区| 水野朝阳av一区二区三区| 3d动漫精品啪啪一区二区竹菊| 免费人成网站在线观看欧美高清| 精品粉嫩超白一线天av| 成人污视频在线观看| 亚洲精品免费在线| 91麻豆精品91久久久久久清纯| 奇米一区二区三区| 久久久亚洲精品一区二区三区| 国产成a人无v码亚洲福利| 亚洲欧美电影一区二区| 欧美乱熟臀69xxxxxx| 久久99久久久欧美国产| 国产精品久久午夜| 欧美午夜精品久久久| 日本欧洲一区二区| 国产午夜精品一区二区 | 久久亚洲二区三区| 91在线一区二区三区| 亚洲一区二区三区视频在线| 日韩欧美在线观看一区二区三区| 国产成人欧美日韩在线电影| 亚洲三级免费电影| 日韩免费看的电影| 成人h动漫精品一区二| 亚洲大片一区二区三区| 久久色视频免费观看| 色丁香久综合在线久综合在线观看| 青青国产91久久久久久| 中文在线免费一区三区高中清不卡| 欧洲生活片亚洲生活在线观看| 美女精品自拍一二三四| 自拍偷拍国产亚洲| 欧美精品一区二区三区很污很色的 | 久久精品国产第一区二区三区| 国产精品美女久久久久久久久| 欧美日韩国产免费一区二区| 国产精品996| 香蕉久久夜色精品国产使用方法| 国产亚洲va综合人人澡精品 | 国产精品传媒入口麻豆| 欧美一卡在线观看| 99久久精品99国产精品| 免费在线观看一区| 玉米视频成人免费看| 久久久久国产免费免费| 欧美高清激情brazzers| 99热精品国产| 国产在线精品免费| 午夜国产不卡在线观看视频| 中文字幕一区二区三区四区 | 天天综合日日夜夜精品| 国产精品久久久久桃色tv| 欧美成人精品二区三区99精品| 欧美三区在线观看| www.成人网.com| 国产乱理伦片在线观看夜一区 | 欧美美女一区二区三区| 99久久免费精品高清特色大片| 国产做a爰片久久毛片| 天堂成人免费av电影一区| 亚洲免费伊人电影| 国产精品萝li| 久久久夜色精品亚洲| 精品国产一二三区| 5566中文字幕一区二区电影| 在线日韩一区二区| 91视频xxxx| 99久免费精品视频在线观看| 国产精品一区二区你懂的| 九色porny丨国产精品| 免费观看一级欧美片| 午夜伊人狠狠久久| 亚洲成va人在线观看| 无吗不卡中文字幕| 日韩精品欧美精品| 日韩精品一二区| 琪琪一区二区三区|