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

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

?? os_sem.c

?? uCOS 2.76官方發布的一套完整的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.76
*********************************************************************************************************
*/

#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;



    cpu_sr = 0;                                       /* Prevent compiler warning                      */
#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;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#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;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    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);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    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) {
#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;
                 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    */
                 (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;
             return ((OS_EVENT *)0);                       /* Semaphore has been deleted               */

        default:
             OS_EXIT_CRITICAL();
             *err = OS_ERR_INVALID_OPT;
             return (pevent);
    }
}
#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.
*
*              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:
*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
香蕉乱码成人久久天堂爱免费| 日本亚洲电影天堂| 日韩成人免费在线| 成人免费三级在线| 宅男噜噜噜66一区二区66| 国产精品乱码久久久久久| 亚洲va在线va天堂| 99久久99久久免费精品蜜臀| 精品久久久久av影院| 亚洲 欧美综合在线网络| www.亚洲在线| 亚洲国产精品成人久久综合一区| 久久精品免费看| 欧美精品99久久久**| 亚洲欧美国产毛片在线| 丰满少妇久久久久久久| 久久蜜桃av一区二区天堂| 日本在线不卡视频| 欧美日韩国产成人在线91| 亚洲国产一区二区三区青草影视| 日本高清不卡aⅴ免费网站| 欧美高清在线视频| 国产精品66部| 国产日韩精品一区二区三区在线| 久久精品国产亚洲a| 日韩三级精品电影久久久| 亚洲chinese男男1069| 欧美专区日韩专区| 亚洲一区av在线| 欧美在线短视频| 亚洲曰韩产成在线| 欧美色综合天天久久综合精品| 一区二区三区在线不卡| 91黄色免费版| 亚洲成人av电影在线| 欧美视频三区在线播放| 三级精品在线观看| 日韩欧美久久一区| 国产激情视频一区二区三区欧美| 久久久噜噜噜久噜久久综合| 国产成人精品影视| 中文字幕日本不卡| 在线观看www91| 亚洲成在线观看| 日韩欧美亚洲一区二区| 国产风韵犹存在线视精品| 国产精品久线在线观看| 日本韩国一区二区| 日本美女一区二区三区| 国产亚洲成aⅴ人片在线观看| 成人动漫在线一区| 一区二区成人在线| 欧美一区二区三区在线观看视频| 久久国产人妖系列| 中文字幕第一区二区| 色欧美片视频在线观看 | 国产精品国产三级国产普通话99| 成人永久aaa| 亚洲午夜在线观看视频在线| 欧美一区二区大片| 丁香一区二区三区| 亚洲一二三四区不卡| 精品国产青草久久久久福利| 波多野结衣在线一区| 婷婷六月综合网| 国产日韩欧美麻豆| 3atv一区二区三区| 成人在线综合网| 日欧美一区二区| 欧美韩国日本不卡| 欧美四级电影在线观看| 国产综合色产在线精品| 亚洲狠狠爱一区二区三区| 久久免费精品国产久精品久久久久 | 日日骚欧美日韩| 中文字幕高清一区| 日韩免费视频一区| 欧美伊人精品成人久久综合97 | 久久疯狂做爰流白浆xx| 国产精品久久一级| 精品久久久久99| 欧美人牲a欧美精品| 国产精品小仙女| 美女视频网站久久| 亚洲一区av在线| 国产精品入口麻豆九色| 日韩欧美一区二区免费| 欧美色偷偷大香| 色哟哟亚洲精品| 成人午夜免费av| 狠狠v欧美v日韩v亚洲ⅴ| 午夜精品一区二区三区免费视频| 中文字幕一区二区三区精华液| 日韩欧美成人一区二区| 欧美日韩免费观看一区三区| 91在线视频播放地址| 风间由美一区二区av101| 精品一区二区久久| 麻豆精品视频在线观看免费| 午夜精品一区在线观看| 午夜欧美一区二区三区在线播放| 有坂深雪av一区二区精品| 国产蜜臀av在线一区二区三区 | 欧美理论在线播放| 91黄色免费观看| 色婷婷综合久久久中文一区二区| 高清在线成人网| 国产裸体歌舞团一区二区| 美女免费视频一区| 精品亚洲成a人| 韩国av一区二区三区四区 | 亚洲国产wwwccc36天堂| 亚洲欧美日本在线| 一区二区三区在线免费播放| 一区二区三区在线高清| 亚洲一级在线观看| 香蕉久久一区二区不卡无毒影院| 午夜视频在线观看一区二区 | 日韩三级视频中文字幕| 精品久久久久久久久久久久久久久| 日韩欧美国产不卡| 久久影院视频免费| 国产欧美1区2区3区| 综合久久综合久久| 一区二区三区在线免费视频| 亚洲第一狼人社区| 免费高清在线视频一区·| 韩国中文字幕2020精品| 丁香亚洲综合激情啪啪综合| 91原创在线视频| 欧美主播一区二区三区美女| 欧美日韩国产一区| 欧美一卡二卡在线| 国产视频一区二区三区在线观看| 国产精品家庭影院| 亚洲精品国产精品乱码不99| 日日骚欧美日韩| 国产精品夜夜嗨| 日本精品免费观看高清观看| 欧美一级精品大片| 国产偷国产偷精品高清尤物| 亚洲久本草在线中文字幕| 美洲天堂一区二卡三卡四卡视频| 国产一区二区精品久久| 91官网在线观看| 精品福利一二区| 亚洲蜜臀av乱码久久精品蜜桃| 日韩精品欧美成人高清一区二区| 国产乱国产乱300精品| k8久久久一区二区三区| 欧美二区三区的天堂| 日本一区二区免费在线| 偷拍自拍另类欧美| 99久久婷婷国产| 欧美一级片在线看| 国产精品久久久久久久午夜片 | 日韩欧美一区二区免费| 亚洲欧洲av在线| 另类人妖一区二区av| 91视视频在线直接观看在线看网页在线看| 欧美日韩精品免费| 国产精品久久99| 久久成人综合网| 欧美区视频在线观看| 国产精品福利一区二区| 精品一区二区三区日韩| 欧美性猛交一区二区三区精品| 国产视频一区不卡| 日本怡春院一区二区| 色综合久久久网| 久久精品一区二区| 免费成人在线观看| 欧美丝袜丝交足nylons图片| 中文字幕av资源一区| 久久综合综合久久综合| 欧美麻豆精品久久久久久| 一区在线中文字幕| 成人性视频免费网站| 日韩三级.com| 日韩激情一区二区| 欧美中文字幕一区二区三区亚洲| 国产精品久久久久精k8| 粉嫩蜜臀av国产精品网站| 精品久久久久99| 麻豆视频观看网址久久| 欧美一区日本一区韩国一区| 一区二区三区**美女毛片| 99久久国产免费看| 亚洲图片欧美激情| 97久久精品人人做人人爽50路| 中文字幕欧美日韩一区| 国产伦精品一区二区三区免费迷 | 91久久精品一区二区二区| 国产精品久久久久久亚洲伦| 国产99久久久国产精品免费看 | 免费高清成人在线| 欧美精品tushy高清| 免费在线看成人av| 欧美mv和日韩mv的网站| 久久精品国产成人一区二区三区|