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

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

?? os_sem.c

?? Turbo C 3.0 + UCOS2 + UCGUI PC學習版本
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.h"
#endif

#if OS_SEM_EN > 0
/*
*********************************************************************************************************
*                                           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,
*                         if 'pevent' is a NULL pointer or,
*                         if you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

#if OS_SEM_ACCEPT_EN > 0
INT16U  OSSemAccept (OS_EVENT *pevent)
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;
#endif    
    INT16U     cnt;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
#endif
    OS_ENTER_CRITICAL();
    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                        */
}
#endif    

/*$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)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_EVENT  *pevent;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        return ((OS_EVENT *)0);                            /* ... can't CREATE from an ISR             */
    }
    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                      */
        pevent->OSEventPtr  = (void *)0;                   /* Unlink from ECB free list                */
        OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
    }
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         DELETE A SEMAPHORE
*
* Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            semaphore.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete semaphore ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the semaphore even if tasks are waiting.
*                                                    In this case, all the tasks pending will be readied.
*
*              err           is a pointer to an error code that can contain one of the following values:
*                            OS_NO_ERR               The call was successful and the semaphore was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the semaphore from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the semaphore
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a semaphore
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the semaphore was successfully deleted.
*
* Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
*                 the semaphore MUST check the return code of OSSemPend().
*              2) OSSemAccept() callers will not know that the intended semaphore has been deleted unless
*                 they check 'pevent' to see that it's a NULL pointer.
*              3) This call can potentially disable interrupts for a long time.  The interrupt disable
*                 time is directly proportional to the number of tasks waiting on the semaphore.
*              4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful in
*                 applications where the semaphore is used for mutual exclusion because the resource(s)
*                 will no longer be guarded by the semaphore.
*********************************************************************************************************
*/

#if OS_SEM_DEL_EN > 0
OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *err = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on semaphore    */
        tasks_waiting = TRUE;                              /* Yes                                      */
    } else {
        tasks_waiting = FALSE;                             /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == FALSE) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 OSEventFreeList     = pevent;             /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *err = OS_NO_ERR;
                 return ((OS_EVENT *)0);                   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err = OS_ERR_TASK_WAITING;
                 return (pevent);
             }

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for semaphore    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             OSEventFreeList     = pevent;                 /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err = OS_NO_ERR;
             return ((OS_EVENT *)0);                       /* Semaphore has been deleted               */

        default:
             OS_EXIT_CRITICAL();
             *err = OS_ERR_INVALID_OPT;
             return (pevent);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区欧美| 视频精品一区二区| 久久久影视传媒| 日韩欧美精品在线| 日韩精品一区二区三区视频播放 | 免费在线观看一区| 久久超级碰视频| 国产久卡久卡久卡久卡视频精品| 国产一区二区三区在线观看精品| 国产丶欧美丶日本不卡视频| 国产99一区视频免费| 成人黄色a**站在线观看| 97久久超碰精品国产| 欧美午夜精品久久久久久孕妇| 欧美日韩美少妇| 欧美精品日日鲁夜夜添| xvideos.蜜桃一区二区| 亚洲欧洲性图库| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲成人av资源| 国精产品一区一区三区mba视频 | 欧美老肥妇做.爰bbww| 日韩欧美中文字幕一区| 国产午夜精品一区二区| 亚洲精品视频在线观看网站| 亚洲一级片在线观看| 国产在线精品视频| 91小视频在线| 精品免费视频一区二区| 亚洲女人小视频在线观看| 五月婷婷另类国产| 国产成人三级在线观看| 欧美中文字幕一区| 国产人妖乱国产精品人妖| 亚洲国产日韩精品| 国产乱人伦偷精品视频不卡| 91麻豆国产香蕉久久精品| 日韩一区二区三区免费观看| 亚洲欧洲精品一区二区精品久久久 | 日本一区二区成人在线| 婷婷夜色潮精品综合在线| 成人深夜在线观看| 欧美电影精品一区二区| 亚洲一区二区五区| 成人av资源站| 亚洲精品一区二区三区在线观看| 亚洲精品成人天堂一二三| 国产一区二区三区免费| 欧美高清视频不卡网| 中文字幕一区二区不卡| 国产精品一区二区视频| 91精品福利在线一区二区三区| 亚洲视频 欧洲视频| 国产精品自拍av| 欧美一区二区三区电影| 亚洲综合图片区| 色婷婷av一区二区三区gif| 国产亚洲精品超碰| 久久er精品视频| 日韩一区二区三区精品视频| 午夜不卡av在线| 欧美日韩免费不卡视频一区二区三区| 亚洲婷婷在线视频| jvid福利写真一区二区三区| 国产午夜精品一区二区三区四区| 久久99国产精品免费网站| 欧美一卡二卡三卡四卡| 婷婷中文字幕一区三区| 制服丝袜成人动漫| 午夜精品福利一区二区蜜股av| 91麻豆福利精品推荐| 综合欧美亚洲日本| 色天使色偷偷av一区二区| 亚洲欧美激情小说另类| 色老汉一区二区三区| 一区二区三区精品视频| 欧美自拍丝袜亚洲| 视频一区中文字幕国产| 日韩一区二区三区在线观看| 老司机午夜精品| 国产无人区一区二区三区| 成人永久免费视频| 亚洲精品美腿丝袜| 欧美日韩亚洲综合一区二区三区 | 久久综合久久综合九色| 国产福利91精品一区| 国产精品麻豆久久久| 在线观看日韩毛片| 石原莉奈在线亚洲三区| 2023国产精华国产精品| 国产成人99久久亚洲综合精品| 亚洲欧洲精品一区二区精品久久久 | 亚洲精品一二三| 欧美日本国产一区| 国产一区在线观看麻豆| 国产欧美精品一区| 欧美性大战久久| 麻豆成人综合网| 国产精品嫩草99a| 欧美日韩国产一二三| 韩国欧美国产1区| 亚洲天堂福利av| 久久女同性恋中文字幕| 不卡高清视频专区| 日韩国产精品大片| 国产视频亚洲色图| 在线观看三级视频欧美| 国产一区二区美女诱惑| 一区二区三区日韩在线观看| 日韩欧美黄色影院| 日本丶国产丶欧美色综合| 麻豆视频观看网址久久| 亚洲欧美二区三区| 久久综合色8888| 欧美午夜一区二区三区| 国产成人在线影院| 午夜精品一区二区三区电影天堂| 久久九九99视频| 欧美日韩五月天| 国产91丝袜在线播放九色| 亚洲国产视频在线| 国产精品久久久久久久久免费樱桃| 欧美日韩在线播放三区四区| 粉嫩蜜臀av国产精品网站| 婷婷久久综合九色综合绿巨人| 国产精品久久久一本精品| 日韩免费看的电影| 欧美精品久久99| 99热精品国产| 国产制服丝袜一区| 日韩电影在线观看电影| 夜夜爽夜夜爽精品视频| 国产精品美女视频| 久久综合色8888| 91精品国产综合久久精品麻豆 | 91精品国产色综合久久久蜜香臀| aa级大片欧美| 国产成人高清在线| 精品一区二区三区免费| 男女视频一区二区| 日韩国产在线一| 日韩影视精彩在线| 午夜欧美视频在线观看| 亚洲午夜在线视频| 夜夜嗨av一区二区三区中文字幕 | 国产电影精品久久禁18| 国产乱码精品一区二区三区忘忧草| 天堂午夜影视日韩欧美一区二区| 亚洲国产日韩a在线播放性色| 一区二区三区在线免费视频| 一二三区精品福利视频| 亚洲精品免费在线播放| 亚洲一区二区三区四区中文字幕| 亚洲免费观看视频| 亚洲乱码国产乱码精品精98午夜 | 久久99国产精品免费| 激情综合五月天| 国产在线精品一区二区不卡了| 激情综合色播激情啊| 国产一区二区三区香蕉| 丁香亚洲综合激情啪啪综合| 本田岬高潮一区二区三区| jvid福利写真一区二区三区| 在线精品国精品国产尤物884a| 一本在线高清不卡dvd| 在线观看免费亚洲| 欧美一二区视频| 久久先锋影音av| 中文字幕一区av| 亚洲影院理伦片| 麻豆精品一区二区av白丝在线| 国产一区视频导航| 99久久伊人精品| 欧美日韩精品一区视频| 久久先锋影音av鲁色资源| 中文字幕在线观看不卡视频| 亚洲一区二区精品3399| 精品一区二区三区在线播放 | 日韩成人伦理电影在线观看| 毛片不卡一区二区| av男人天堂一区| 欧美剧在线免费观看网站| 精品欧美久久久| 亚洲日本电影在线| 蜜桃久久久久久| 99国产精品久久| 日韩三级在线免费观看| 中文字幕一区在线观看视频| 天天综合网 天天综合色| 国产精品影视在线观看| 欧美麻豆精品久久久久久| 国产欧美日韩精品一区| 午夜精品aaa| 91视频一区二区三区| 日韩欧美一级二级三级| 一区二区不卡在线播放 | 国产性做久久久久久| 亚洲高清免费一级二级三级| 国产91对白在线观看九色| 欧美精品久久一区二区三区|