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

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

?? os_sem.c

?? 基于Verilog HDL的電梯系統設計
?? 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 "..\APP\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一区二区三区免费野_久草精品视频
欧美日韩夫妻久久| 图片区小说区区亚洲影院| 国产精品国产精品国产专区不蜜 | 成人免费毛片片v| 91蝌蚪porny九色| 欧美高清dvd| 久久久久国产精品麻豆ai换脸 | 色噜噜狠狠一区二区三区果冻| 欧美日韩一区二区电影| 日韩精品中文字幕在线一区| 国产精品乱码一区二区三区软件 | 欧洲生活片亚洲生活在线观看| 777精品伊人久久久久大香线蕉| 精品国产91乱码一区二区三区| 中文字幕日韩一区二区| 首页综合国产亚洲丝袜| 国产成人免费视频一区| 欧美艳星brazzers| 久久综合给合久久狠狠狠97色69| 国产精品久久久久影院亚瑟| 日韩精品福利网| 波多野结衣精品在线| 51精品秘密在线观看| 国产精品久久福利| 青青青爽久久午夜综合久久午夜| 国产成人精品午夜视频免费| 欧美日韩亚洲综合| 国产精品网友自拍| 免费观看一级欧美片| 色视频成人在线观看免| 久久你懂得1024| 天天色天天操综合| 99re视频这里只有精品| 精品国产一区二区在线观看| 亚洲综合色婷婷| 成人在线视频一区二区| 日韩久久久精品| 亚洲国产精品影院| 成人av资源站| 26uuu国产一区二区三区| 午夜精品福利一区二区三区av| 成人网页在线观看| 久久奇米777| 奇米精品一区二区三区四区 | 亚洲人123区| 国产精品性做久久久久久| 3d成人动漫网站| 一区二区三区欧美| 不卡一区二区中文字幕| 久久午夜电影网| 九色综合国产一区二区三区| 欧美日韩精品一区二区三区| 亚洲精品日韩专区silk| 成人午夜视频网站| 久久精品亚洲麻豆av一区二区| 日韩成人av影视| 在线电影院国产精品| 亚洲综合在线五月| 色94色欧美sute亚洲线路二| 中文字幕欧美激情一区| 国产一区二区剧情av在线| 欧美一区二区精品久久911| 亚洲午夜一区二区| 欧美色涩在线第一页| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 成人免费观看男女羞羞视频| 精品国产一区二区三区忘忧草| 日韩高清在线观看| 欧美福利视频导航| 性做久久久久久免费观看欧美| 精品视频一区二区不卡| 亚洲综合激情另类小说区| 91蜜桃婷婷狠狠久久综合9色| 国产精品免费丝袜| 成人黄动漫网站免费app| 国产婷婷色一区二区三区在线| 狠狠色丁香久久婷婷综合丁香| 26uuu精品一区二区三区四区在线| 蜜桃av一区二区三区电影| 日韩欧美亚洲另类制服综合在线| 青青草97国产精品免费观看无弹窗版| 精品视频一区二区不卡| 日本网站在线观看一区二区三区| 91精品国产综合久久国产大片| 日本女优在线视频一区二区| 日韩欧美国产小视频| 激情文学综合插| 国产欧美精品区一区二区三区| 成人精品视频一区二区三区尤物| 《视频一区视频二区| 欧美在线不卡视频| 日本成人在线看| 久久综合成人精品亚洲另类欧美 | 久久欧美中文字幕| 成人av电影在线网| 一区二区三区欧美| 日韩欧美在线综合网| 激情五月婷婷综合| 中文字幕制服丝袜成人av| 色综合久久久久久久久久久| 亚洲国产精品久久久男人的天堂| 欧美日韩国产天堂| 激情六月婷婷综合| 欧美激情一区二区三区| 97精品国产露脸对白| 一区二区三区精品在线| 91精品在线麻豆| 国产成人在线视频网址| 亚洲欧美福利一区二区| 91麻豆精品国产91久久久资源速度| 免费欧美高清视频| 亚洲国产精品传媒在线观看| 色久综合一二码| 久久国产尿小便嘘嘘尿| 中文字幕中文字幕一区| 在线成人免费观看| 国产精品亚洲人在线观看| 一区二区三区色| 日韩午夜电影av| 不卡一区二区中文字幕| 日韩国产高清在线| 中文字幕一区二区在线播放| 欧美日韩一二三区| 国产成人日日夜夜| 亚洲成人综合在线| 久久久久9999亚洲精品| 欧美午夜一区二区三区| 国产成人午夜视频| 亚洲一区二区三区不卡国产欧美| 精品国产亚洲一区二区三区在线观看| 99视频精品全部免费在线| 免费看欧美女人艹b| 日韩美女精品在线| 精品国产一区二区亚洲人成毛片| 色欧美片视频在线观看在线视频| 久久精品国产精品亚洲综合| 亚洲另类在线一区| 久久久久国色av免费看影院| 欧美亚洲国产一区二区三区| 国产高清视频一区| 三级精品在线观看| 国产精品视频看| 精品国免费一区二区三区| 欧美在线观看一二区| 成人免费va视频| 精品在线你懂的| 午夜国产不卡在线观看视频| 国产精品国产自产拍在线| 欧美成人三级电影在线| 欧美视频一区二区在线观看| 成人性生交大片免费看在线播放 | 日韩欧美专区在线| 色香蕉久久蜜桃| 国产精品影视在线观看| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲乱码日产精品bd| 国产欧美日韩精品a在线观看| 91精品视频网| 欧美网站大全在线观看| 91在线小视频| 国产不卡在线一区| 国产在线精品不卡| 日韩激情一区二区| 亚洲国产欧美在线人成| 亚洲色图清纯唯美| 欧美激情综合在线| 久久久亚洲精品一区二区三区| 欧美高清视频不卡网| 欧美午夜电影一区| 在线观看欧美黄色| 一本到高清视频免费精品| 成人涩涩免费视频| 高清shemale亚洲人妖| 国产精品一二三区在线| 激情丁香综合五月| 精品一区在线看| 久久aⅴ国产欧美74aaa| 免费的国产精品| 日韩福利电影在线| 午夜视频在线观看一区二区三区| 依依成人综合视频| 亚洲美女电影在线| 亚洲欧美日韩国产综合| 亚洲婷婷国产精品电影人久久| 国产精品久久毛片av大全日韩| 欧美国产日韩a欧美在线观看| 国产亚洲成年网址在线观看| 精品久久久久久亚洲综合网| www欧美成人18+| 国产无遮挡一区二区三区毛片日本| 国产日产欧美一区二区视频| 国产婷婷精品av在线| 亚洲欧洲精品天堂一级| 亚洲免费在线播放| 亚洲成人免费看| 蓝色福利精品导航| 盗摄精品av一区二区三区| 一本色道a无线码一区v| 欧美中文字幕一二三区视频| 欧美日韩中文字幕精品|