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

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

?? os_sem.c

?? UCOS最新版本。VERSION 2.80。完整
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2005, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.80
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include <ucos_ii.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)
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
    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)
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



    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                */
#if OS_EVENT_NAME_SIZE > 1
        pevent->OSEventName[0] = '?';                      /* Unknown name                             */
        pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
        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)
{
    BOOLEAN    tasks_waiting;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (err == (INT8U *)0) {                               /* Validate 'err'                           */
        return (pevent);
    }
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *err = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0) {                         /* 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) {
#if OS_EVENT_NAME_SIZE > 1
                 pevent->OSEventName[0] = '?';             /* Unknown name                             */
                 pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
                 pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
                 pevent->OSEventCnt     = 0;
                 OSEventFreeList        = pevent;          /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *err                   = OS_NO_ERR;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err                   = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0) {             /* Ready ALL tasks waiting for semaphore    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
#if OS_EVENT_NAME_SIZE > 1
             pevent->OSEventName[0] = '?';                 /* Unknown name                             */
             pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
             pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
             pevent->OSEventCnt     = 0;
             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;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *err                   = OS_ERR_INVALID_OPT;
             pevent_return          = pevent;
             break;
    }
    return (pevent_return);
}
#endif

/*$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.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产高清一区二区三区 | 日韩激情av在线| 亚洲高清视频中文字幕| 亚洲国产精品一区二区久久 | 国产成人免费9x9x人网站视频| 九一九一国产精品| 成人a免费在线看| 欧美日韩免费一区二区三区视频| 欧美妇女性影城| 国产欧美一区二区三区在线看蜜臀| 国产日韩欧美精品综合| 亚洲成人av在线电影| 国产伦精品一区二区三区在线观看 | 在线成人高清不卡| 欧美xxxxx牲另类人与| 亚洲精品一二三| 国产精品99久久久久久似苏梦涵| 色94色欧美sute亚洲线路一久 | 3751色影院一区二区三区| 久久久国际精品| 久久99久久99| 欧美喷潮久久久xxxxx| 亚洲国产成人午夜在线一区| 蜜桃视频一区二区| 91久久人澡人人添人人爽欧美| 亚洲精品一区二区精华| 亚洲激情av在线| 国产电影一区在线| 极品少妇一区二区| 欧美剧情片在线观看| 中文字幕一区二区三区精华液| 日韩成人免费在线| 9191精品国产综合久久久久久| 久久久电影一区二区三区| 国产精品白丝在线| 看电视剧不卡顿的网站| 欧美精品 日韩| 水蜜桃久久夜色精品一区的特点| 欧美日韩亚洲综合一区| 亚洲欧美电影院| 一本大道av伊人久久综合| 亚洲一区二区3| 久久嫩草精品久久久精品| 国产成人精品亚洲日本在线桃色| 久久精品夜夜夜夜久久| 精品一区二区在线观看| 国产精品久久综合| 91官网在线观看| 久久福利资源站| 亚洲人成网站色在线观看| 欧美日韩精品系列| 精品无人码麻豆乱码1区2区| 久久精品亚洲国产奇米99| 99麻豆久久久国产精品免费| 亚洲国产精品嫩草影院| 国产欧美日韩另类视频免费观看| 97久久精品人人做人人爽50路| 亚洲精选一二三| 久久这里只精品最新地址| 欧美亚洲一区三区| 成人在线视频一区| 美国三级日本三级久久99| 一区二区三区精密机械公司| 日韩欧美国产小视频| 在线免费观看一区| 成人性生交大片免费看视频在线 | 欧美色图12p| 狠狠色狠狠色综合系列| 亚洲综合色视频| 国产精品久久久久毛片软件| 欧美一区二区大片| 欧美人体做爰大胆视频| 成人av综合在线| 99精品桃花视频在线观看| 高清av一区二区| 成人在线视频首页| av一区二区三区四区| 国产成人精品综合在线观看| 国产伦精一区二区三区| 激情综合色播激情啊| 国产一区二区三区黄视频 | 欧美精品欧美精品系列| 99久久婷婷国产精品综合| 粉嫩av一区二区三区在线播放| 成人激情图片网| 久久影院视频免费| 日本aⅴ精品一区二区三区| 99视频精品全部免费在线| 欧美xxx久久| 日本少妇一区二区| 欧美日韩中文精品| 亚洲激情五月婷婷| 91麻豆自制传媒国产之光| 精品福利视频一区二区三区| 天涯成人国产亚洲精品一区av| av中文字幕一区| 亚洲精品写真福利| 一本久久a久久免费精品不卡| 久久精品一区二区三区四区| 亚洲精品中文字幕在线观看| 国产电影精品久久禁18| 欧美精品久久99久久在免费线 | 美女视频第一区二区三区免费观看网站| 看电影不卡的网站| 精品捆绑美女sm三区| 亚洲视频一区在线| 国产福利一区二区| 久久久久久久性| 韩国女主播一区| 337p粉嫩大胆噜噜噜噜噜91av| 一区二区三区四区中文字幕| 色综合视频在线观看| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 久久免费美女视频| 日韩电影在线一区二区| 亚洲国产视频一区二区| 91免费精品国自产拍在线不卡| 91成人在线精品| 一区二区三区高清| 欧美成人精品1314www| 成人午夜视频福利| 天天色天天操综合| 中文字幕不卡在线播放| 色婷婷香蕉在线一区二区| 亚洲大片一区二区三区| 国产成人精品综合在线观看| 欧美mv日韩mv亚洲| 麻豆精品新av中文字幕| 国产片一区二区三区| 欧美在线观看一区二区| 久久精品国产**网站演员| 自拍偷拍亚洲综合| 日韩精品在线网站| 色综合色狠狠天天综合色| 美女视频黄 久久| 亚洲色图另类专区| 久久久久久久久久电影| 精品视频全国免费看| 成人18视频在线播放| 久久99精品国产麻豆婷婷| 亚洲一区二区五区| 亚洲女与黑人做爰| 国产无一区二区| 欧美精品一区二区在线观看| 精品污污网站免费看| 色婷婷久久一区二区三区麻豆| 国产精品自拍三区| 久久er99精品| 免费三级欧美电影| 日本vs亚洲vs韩国一区三区二区 | a在线播放不卡| 成人一二三区视频| 成人午夜视频在线观看| 久久精品二区亚洲w码| 国产精品久久久久一区| 9191成人精品久久| 精品亚洲成a人| 欧美美女黄视频| 亚洲不卡一区二区三区| www.在线成人| 国产精品三级电影| 色域天天综合网| 亚洲一区在线电影| 欧美高清你懂得| 成人一区二区在线观看| 亚洲日本中文字幕区| 欧美四级电影在线观看| 久热成人在线视频| 国产精品久久福利| 在线亚洲一区观看| 国产在线精品免费| 亚洲一区二区三区四区五区黄 | 午夜伊人狠狠久久| 日韩一卡二卡三卡四卡| 99久久伊人网影院| 国产精品影音先锋| 日韩av一二三| 国产精品国产三级国产专播品爱网 | 日韩一区二区三| 欧美伊人久久久久久久久影院| 成人深夜在线观看| 悠悠色在线精品| 日韩午夜在线影院| 国产999精品久久久久久| 亚洲伦理在线免费看| 久久久噜噜噜久久人人看| 欧美日韩免费一区二区三区视频| 欧美日韩在线播| 亚洲一区在线视频观看| 一本一道综合狠狠老| 亚洲欧洲日本在线| 国产精品香蕉一区二区三区| 国产精品欧美久久久久无广告 | 中文字幕乱码亚洲精品一区| 成人黄色综合网站| 一区二区三区免费网站| 日韩一区二区不卡| 成人在线综合网站| 亚洲成人黄色小说| 精品一区二区三区影院在线午夜 |