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

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

?? os_sem.c

?? ucos2shell yy code
?? 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一区二区三区免费野_久草精品视频
亚洲成av人影院在线观看网| 日韩精品每日更新| 7777精品伊人久久久大香线蕉的 | 国产日韩精品一区| 欧美日韩午夜精品| 成人av网站在线观看| 视频一区视频二区中文| 中文av一区二区| 日韩免费性生活视频播放| 色婷婷久久综合| 国产福利不卡视频| 蜜桃av噜噜一区| 亚洲蜜臀av乱码久久精品| 久久久久久久久久久久久夜| 欧美三级中文字幕| 91蜜桃传媒精品久久久一区二区| 国产在线一区观看| 三级欧美在线一区| 亚洲午夜在线视频| 亚洲日本丝袜连裤袜办公室| 久久精品一区四区| 欧美成人免费网站| 欧美日韩国产精选| 欧美色中文字幕| 在线视频一区二区三区| 成人午夜私人影院| 国产xxx精品视频大全| 捆绑紧缚一区二区三区视频| 午夜av一区二区| 亚洲国产精品一区二区久久恐怖片| 亚洲视频一区在线观看| 国产精品国产三级国产普通话99| 久久综合九色综合欧美亚洲| 日韩欧美国产一区二区在线播放| 欧美一区二区三级| 91精品国产综合久久精品app| 欧美三片在线视频观看| 欧美午夜精品久久久久久超碰| 91亚洲永久精品| 99久久亚洲一区二区三区青草| 成人免费不卡视频| 成人av小说网| 色综合久久综合网97色综合| 91在线看国产| 91国偷自产一区二区三区观看| 91在线精品一区二区三区| 一本到高清视频免费精品| 99re热这里只有精品免费视频| av网站一区二区三区| 99热这里都是精品| 欧美影院一区二区三区| 欧美日精品一区视频| 在线成人av网站| 日韩欧美综合一区| 国产亚洲欧美激情| 日韩理论片网站| 亚洲午夜久久久久久久久久久| 天堂资源在线中文精品| 麻豆国产一区二区| 成人午夜看片网址| 日本高清视频一区二区| 91精品国产综合久久久久久漫画 | 韩日欧美一区二区三区| 国产乱码精品一区二区三区av| 国产精品一区二区在线看| 波多野结衣视频一区| 在线看国产日韩| 欧美一区二区三区播放老司机| 久久这里只精品最新地址| 国产精品久久免费看| 一级中文字幕一区二区| 蜜桃av一区二区| 99久久精品久久久久久清纯| 欧美亚洲日本国产| 欧美zozozo| 亚洲精品乱码久久久久久日本蜜臀| 亚洲成人动漫在线观看| 国产曰批免费观看久久久| 91亚洲大成网污www| 在线成人午夜影院| 国产精品久线观看视频| 五月开心婷婷久久| 国产a视频精品免费观看| 欧美亚洲国产bt| 久久影院午夜论| 亚洲综合精品自拍| 国模冰冰炮一区二区| 91国产丝袜在线播放| 2023国产精品视频| 亚洲成人1区2区| 成人污污视频在线观看| 日韩一区二区在线播放| 亚洲精品国产第一综合99久久| 久久国产免费看| 欧美视频中文字幕| 国产欧美一区二区精品性| 午夜精品aaa| 91性感美女视频| 国产婷婷一区二区| 天天综合天天综合色| 成人av在线网站| 久久久一区二区| 日韩va亚洲va欧美va久久| 91免费视频观看| 国产欧美一区二区精品秋霞影院| 婷婷开心激情综合| 色一区在线观看| 中文字幕av一区二区三区高| 秋霞电影网一区二区| 色噜噜夜夜夜综合网| 亚洲国产成人一区二区三区| 免费在线观看视频一区| 欧美酷刑日本凌虐凌虐| 亚洲欧美成人一区二区三区| 国产成人激情av| 精品国产一区二区亚洲人成毛片| 亚洲成人一区二区| 色呦呦网站一区| 国产精品国产自产拍高清av王其| 国产福利一区在线| 精品久久久久久久久久久久包黑料 | 国产一区91精品张津瑜| 日韩欧美在线网站| 日韩1区2区3区| 欧美日韩国产123区| 一区二区日韩av| 在线视频一区二区三区| 亚洲精品精品亚洲| 一本色道**综合亚洲精品蜜桃冫| 国产亚洲短视频| 国产高清精品网站| 国产欧美日本一区视频| 大白屁股一区二区视频| 中文字幕国产精品一区二区| 高清免费成人av| 国产精品视频一二三区| 成人自拍视频在线| 中文字幕在线观看一区二区| 成人手机在线视频| 中文字幕制服丝袜一区二区三区 | 午夜视频一区二区三区| 在线观看区一区二| 亚洲一本大道在线| 欧美精品vⅰdeose4hd| 欧美bbbbb| 日韩欧美中文字幕制服| 国产一区二区h| 国产精品久久久一区麻豆最新章节| 丁香桃色午夜亚洲一区二区三区| 国产精品三级av在线播放| 97aⅴ精品视频一二三区| 亚洲免费伊人电影| 欧美精品久久天天躁| 热久久久久久久| 久久精品一区二区三区不卡牛牛| 岛国精品一区二区| 亚洲欧美激情视频在线观看一区二区三区 | 日韩—二三区免费观看av| 欧美一级二级三级乱码| 国产一区二区毛片| 亚洲人xxxx| 91精品国产欧美日韩| 国内精品免费在线观看| 成人欧美一区二区三区在线播放| 91久久精品一区二区三区| 日韩国产成人精品| 亚洲国产精品t66y| 欧美日韩国产小视频| 久久99国内精品| 亚洲欧美日韩成人高清在线一区| 欧美肥妇bbw| 国产电影一区在线| 亚洲黄色免费电影| 精品久久久久av影院| 91麻豆swag| 久久国产精品免费| 国产精品福利影院| 欧美日本在线播放| 国产99精品在线观看| 亚洲成人精品一区| 国产日韩精品一区| 91精品欧美综合在线观看最新| 国产精品亚洲专一区二区三区| 亚洲特黄一级片| 精品国精品自拍自在线| 色中色一区二区| 国产精品系列在线播放| 亚洲国产三级在线| 亚洲国产精品精华液ab| 91精品国产美女浴室洗澡无遮挡| av高清不卡在线| 激情小说欧美图片| 亚洲地区一二三色| 国产精品久久久久永久免费观看| 欧美日韩国产首页在线观看| 白白色亚洲国产精品| 狠狠色狠狠色综合系列| 日韩—二三区免费观看av| 亚洲日本在线看| 久久久亚洲精华液精华液精华液 |