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

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

?? os_sem.c

?? 可以在51上運行的操作系統
?? 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一区二区三区免费野_久草精品视频
五月开心婷婷久久| 亚洲欧洲日韩综合一区二区| 91麻豆国产香蕉久久精品| 国产麻豆精品在线观看| 日本vs亚洲vs韩国一区三区二区 | 亚洲欧美一区二区在线观看| 久久久精品日韩欧美| 精品久久国产97色综合| 欧美成人精品1314www| 久久久不卡影院| 亚洲国产高清在线| 亚洲欧洲精品天堂一级 | 精品国产乱码久久久久久闺蜜 | 国产成人av资源| 成人午夜电影久久影院| 99久久久精品| 欧美在线短视频| 欧美一区二区免费观在线| 精品日本一线二线三线不卡| 国产视频一区在线播放| 国产精品久久毛片av大全日韩| 中文字幕一区二区三区视频 | 久久亚洲捆绑美女| 中国色在线观看另类| 一区二区三区蜜桃| 日韩高清欧美激情| 国产白丝精品91爽爽久久| 91老师片黄在线观看| 欧美剧情片在线观看| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 美日韩一级片在线观看| 国产成人aaaa| 欧美日韩精品福利| 国产日韩欧美在线一区| 亚洲女女做受ⅹxx高潮| 日本vs亚洲vs韩国一区三区 | 91精品国产91久久久久久一区二区 | 99久久精品国产网站| 91精品视频网| 中文字幕一区在线| 日韩av一区二| 色综合久久久久| 久久视频一区二区| 午夜视频在线观看一区二区三区| 国产在线视视频有精品| 欧美日韩在线免费视频| 国产精品丝袜久久久久久app| 日韩高清不卡一区| 色欧美日韩亚洲| 欧美国产1区2区| 精品一区二区三区在线播放视频| 在线这里只有精品| 国产精品久久久久久久蜜臀| 日韩va欧美va亚洲va久久| 91色porny| 国产精品视频线看| 韩国一区二区三区| 91精品国产入口| 亚洲狠狠爱一区二区三区| www.av亚洲| 国产精品久久三区| 国产不卡在线播放| 欧美激情中文不卡| 国产精品综合一区二区| 欧美电影免费观看完整版| 亚洲va天堂va国产va久| 在线亚洲免费视频| 亚洲激情图片qvod| 91国产免费看| 一区二区三区免费观看| 欧美亚洲国产一区二区三区va | 在线观看日韩电影| 亚洲欧美激情插| 一本色道久久综合亚洲精品按摩| 国产精品色噜噜| 99麻豆久久久国产精品免费| 久久精品一区蜜桃臀影院| 国产在线不卡视频| 国产婷婷一区二区| 成人免费va视频| ㊣最新国产の精品bt伙计久久| 99精品视频在线观看| 亚洲色图在线视频| 欧美色倩网站大全免费| 亚洲成人久久影院| 精品国产一区二区三区久久影院| 国产伦精品一区二区三区免费迷| 久久亚洲精华国产精华液| 国产成人精品一区二区三区网站观看| 日本一区二区视频在线观看| jiyouzz国产精品久久| 亚洲欧美成人一区二区三区| 欧美亚洲免费在线一区| 久久丁香综合五月国产三级网站 | 成人免费va视频| 一区二区在线观看视频| 欧美日本一区二区在线观看| 美日韩一区二区三区| 国产精品人妖ts系列视频| 91福利在线观看| 老色鬼精品视频在线观看播放| 久久精品人人做人人爽人人| aaa亚洲精品| 日韩福利电影在线| 亚洲欧洲成人自拍| 欧美一区二区在线免费观看| 国产精品1区2区3区| 亚洲欧美国产毛片在线| 日韩免费观看高清完整版在线观看| 国产98色在线|日韩| 亚洲国产乱码最新视频 | 免费看欧美女人艹b| 国产欧美精品一区二区色综合| 色综合久久六月婷婷中文字幕| 毛片不卡一区二区| 亚洲精品视频免费看| 337p日本欧洲亚洲大胆精品 | 日韩午夜av一区| 99久久99久久精品免费看蜜桃| 爽好久久久欧美精品| 最新高清无码专区| 欧美mv日韩mv国产网站app| 色综合欧美在线| 国产成人在线观看| 美国毛片一区二区| 午夜久久久久久久久| 亚洲婷婷综合色高清在线| 欧美videofree性高清杂交| 欧美视频三区在线播放| 99久久久国产精品免费蜜臀| 紧缚奴在线一区二区三区| 亚洲bt欧美bt精品| 亚洲乱码国产乱码精品精小说 | 成人精品免费网站| 激情五月激情综合网| 午夜日韩在线观看| 亚洲图片自拍偷拍| 亚洲精品久久久蜜桃| 中文字幕中文字幕在线一区 | 亚洲123区在线观看| 亚洲图片你懂的| 国产精品国产精品国产专区不蜜| 久久亚洲精精品中文字幕早川悠里 | 99精品视频在线观看免费| 国产精品18久久久久久vr| 美女www一区二区| 免费视频一区二区| 青娱乐精品在线视频| 香蕉成人啪国产精品视频综合网| 一区二区免费在线播放| 亚洲精选一二三| 一区二区三区在线影院| 成人欧美一区二区三区1314| 亚洲欧洲精品天堂一级| 亚洲视频综合在线| 亚洲精品v日韩精品| 亚洲一区二区在线观看视频| 亚洲综合色视频| 天堂资源在线中文精品| 视频一区视频二区中文字幕| 免费在线观看一区| 另类中文字幕网| 国产精品一区二区久久精品爱涩| 国模套图日韩精品一区二区| 国产伦理精品不卡| av一区二区三区四区| 在线观看不卡视频| 777色狠狠一区二区三区| 日韩视频在线你懂得| 2024国产精品视频| 亚洲欧美日韩综合aⅴ视频| 一区二区三区av电影| 午夜精品一区二区三区三上悠亚| 欧美bbbbb| 成人福利视频网站| 欧美系列一区二区| 欧美成人免费网站| 1000部国产精品成人观看| 亚洲另类在线一区| 蜜桃免费网站一区二区三区 | 亚洲三级在线免费观看| 午夜精品福利一区二区蜜股av | 99热这里都是精品| 欧美精品v国产精品v日韩精品| 日韩亚洲欧美成人一区| 中文字幕成人网| 日韩电影在线一区二区三区| 国产剧情一区二区| 欧美日韩视频不卡| 国产欧美日韩综合精品一区二区| 亚洲区小说区图片区qvod| 午夜激情一区二区三区| 国产aⅴ综合色| 欧美三级日韩三级| 欧美高清在线精品一区| 日韩高清一区二区| 在线一区二区三区四区五区| 久久噜噜亚洲综合| 婷婷国产v国产偷v亚洲高清| 风间由美一区二区三区在线观看|