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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? 這是一個(gè)UCOS程序
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
*********************************************************************************************************
*                                                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:
*

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本不卡不码高清免费观看 | 欧美日本在线播放| 99久久精品国产导航| 国产91精品免费| 成人午夜在线视频| 成人性生交大片免费看视频在线 | 天使萌一区二区三区免费观看| 亚洲女同一区二区| 自拍偷拍欧美精品| 亚洲精品视频在线| 亚洲一卡二卡三卡四卡| 亚洲成人av福利| 亚洲一区二区精品视频| 久久se这里有精品| a在线播放不卡| 成人97人人超碰人人99| caoporen国产精品视频| 91麻豆精品秘密| 欧美又粗又大又爽| 欧美精品日韩综合在线| 欧美一区二区三区四区高清| 日韩一区二区在线播放| 亚洲精品一线二线三线无人区| 久久久精品2019中文字幕之3| 欧美国产在线观看| 亚洲日本va在线观看| 亚洲精品国产无天堂网2021| 午夜av区久久| 久久99精品国产麻豆婷婷| 成人一区二区三区中文字幕| 日本乱码高清不卡字幕| 91精品午夜视频| 久久久国产综合精品女国产盗摄| 国产精品福利电影一区二区三区四区| 有码一区二区三区| 免费看黄色91| 不卡一二三区首页| 欧美日韩大陆在线| 久久一夜天堂av一区二区三区| 亚洲欧洲色图综合| 青青草视频一区| 成人av在线电影| 欧美日韩二区三区| 国产三级久久久| 亚洲午夜av在线| 国产中文一区二区三区| 色综合久久中文字幕综合网| 这里只有精品99re| 国产精品久久二区二区| 日韩国产欧美三级| 成人网页在线观看| 91 com成人网| 国产精品精品国产色婷婷| 日韩精品电影一区亚洲| 高清在线不卡av| 欧美男女性生活在线直播观看| 久久夜色精品国产噜噜av| 亚洲一区在线视频观看| 国产高清不卡一区二区| 欧美日韩一区二区在线观看| 久久久久9999亚洲精品| 午夜精品久久久久久久久久| 成人精品国产福利| 欧美一区日韩一区| 亚洲欧美另类小说| 极品少妇一区二区| 欧美亚男人的天堂| 中文一区在线播放| 久久99在线观看| 欧美日韩亚洲不卡| 中文字幕一区二区不卡| 激情国产一区二区| 欧美日韩电影一区| 亚洲精选免费视频| 国产精品 欧美精品| 日韩欧美中文字幕一区| 亚洲一区二区三区自拍| 成人美女在线观看| 久久精品人人做人人爽人人| 美女脱光内衣内裤视频久久网站| 99精品欧美一区二区蜜桃免费| 久久久久久**毛片大全| 蜜桃视频一区二区三区在线观看 | 日韩免费视频一区二区| 一区二区三区欧美久久| 国产大陆精品国产| 欧美xfplay| 蜜臀av一区二区在线免费观看| 欧美性猛片aaaaaaa做受| 综合久久久久久久| 国产999精品久久| 久久久久久免费毛片精品| 久久国内精品视频| 精品欧美一区二区在线观看| 天天影视涩香欲综合网| 欧美日韩精品一区二区在线播放| 亚洲猫色日本管| 成人av电影在线| 国产精品萝li| 北条麻妃一区二区三区| 国产精品视频线看| 国产美女久久久久| 久久久久亚洲蜜桃| 国产一区二区美女| 国产视频一区在线观看| 国产精品123区| 国产欧美日韩在线| 丁香婷婷综合五月| 国产精品久久久久精k8 | 中文字幕av一区二区三区免费看| 国产精品99久久久久| 日本一区二区三区在线不卡 | 久久久久久久久97黄色工厂| 久久精品噜噜噜成人av农村| 精品噜噜噜噜久久久久久久久试看| 免费人成网站在线观看欧美高清| 欧美成人三级电影在线| 精品一区二区在线视频| 亚洲精品一线二线三线无人区| 国产一区二区中文字幕| 国产精品视频一区二区三区不卡| 91在线视频网址| 一区二区三区四区高清精品免费观看| 色一情一伦一子一伦一区| 亚洲一级不卡视频| 欧美一区二区三区视频在线观看| 免费在线观看一区| 精品久久国产老人久久综合| 国产伦精品一区二区三区免费迷| 亚洲国产精品精华液ab| 91亚洲国产成人精品一区二三| 亚洲一区视频在线| 日韩视频一区在线观看| 国产福利一区二区三区| 亚洲欧美另类久久久精品| 欧美精选午夜久久久乱码6080| 久久99久久久欧美国产| 亚洲国产精品av| 色综合 综合色| 免费人成精品欧美精品| 国产欧美精品日韩区二区麻豆天美| 99久久精品国产精品久久 | 91色在线porny| 午夜久久久影院| 亚洲国产精品精华液2区45| 91国产福利在线| 国产在线精品一区二区夜色| 国产精品毛片大码女人| 欧美久久久久免费| 国产ts人妖一区二区| 亚洲一区二区三区视频在线| 久久综合色天天久久综合图片| 色综合久久综合中文综合网| 奇米色一区二区| 一区在线观看免费| 欧美一区二区人人喊爽| 成人avav影音| 裸体在线国模精品偷拍| 最新高清无码专区| 日韩精品一区二区三区四区| 成人爱爱电影网址| 蜜臀av性久久久久蜜臀aⅴ四虎 | 国产日韩欧美不卡| 欧美日韩国产电影| 北条麻妃一区二区三区| 免费在线一区观看| 一区二区国产盗摄色噜噜| 久久新电视剧免费观看| 欧美日韩国产乱码电影| 成人99免费视频| 极品少妇一区二区三区精品视频| 一区二区三区四区五区视频在线观看| 久久久久久久电影| 欧美精品免费视频| 91视频xxxx| 国产ts人妖一区二区| 精品一区二区日韩| 性欧美大战久久久久久久久| 国产日韩影视精品| 欧美不卡123| 欧美精品丝袜久久久中文字幕| 91麻豆免费观看| 国产成人av影院| 精品亚洲成av人在线观看| 亚洲va欧美va人人爽| 1区2区3区精品视频| 国产日韩欧美亚洲| 日韩欧美二区三区| 欧美一区二区视频在线观看 | 一区二区三区不卡在线观看| 国产精品免费人成网站| 久久久亚洲午夜电影| 日韩欧美一区电影| 91.com视频| 在线播放一区二区三区| 欧美伊人久久久久久久久影院 | 亚洲精选视频在线| 亚洲三级理论片| 国产精品国产精品国产专区不片| 国产日韩欧美不卡在线|