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

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

?? os_sem.c

?? 全部源代碼參考別人是怎么寫代碼
?? 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一区二区三区免费野_久草精品视频
久久99精品久久久久久| 日韩和欧美一区二区三区| 日韩午夜av一区| 在线亚洲一区二区| 国产v日产∨综合v精品视频| 久久精品噜噜噜成人av农村| 免费成人在线观看| 久久国产免费看| 极品少妇xxxx精品少妇偷拍| 国产真实乱子伦精品视频| 国产精品69久久久久水密桃| 久久99热这里只有精品| 国产伦精品一区二区三区在线观看| 奇米精品一区二区三区四区| 国内精品不卡在线| caoporen国产精品视频| 99精品久久久久久| 在线观看视频91| 日韩一级二级三级| www国产成人| 中文字幕在线不卡一区| 亚洲色图.com| 亚洲午夜精品网| 日本欧美一区二区三区| 国产精品原创巨作av| 91视视频在线观看入口直接观看www| 一本大道久久a久久精二百| 884aa四虎影成人精品一区| 91精品黄色片免费大全| 久久久久久黄色| 亚洲乱码国产乱码精品精的特点| 亚洲一区二区欧美日韩| 狠狠色综合日日| jizzjizzjizz欧美| 欧美美女黄视频| 国产视频一区在线播放| 亚洲国产欧美日韩另类综合 | 国内精品视频666| 色综合网色综合| 精品国产乱码久久久久久久| 国产精品丝袜久久久久久app| 亚洲精品国产无套在线观| 美女脱光内衣内裤视频久久影院| 豆国产96在线|亚洲| 欧美伦理影视网| 亚洲人午夜精品天堂一二香蕉| 丝袜诱惑制服诱惑色一区在线观看 | 国产精品一二三| 欧美三级视频在线播放| 欧美精品一区男女天堂| 亚洲精品欧美在线| 国产高清在线观看免费不卡| 91.麻豆视频| 1区2区3区欧美| 国产精品538一区二区在线| 在线免费观看日韩欧美| 久久久久青草大香线综合精品| 亚洲一级在线观看| 91蝌蚪国产九色| 国产日韩av一区二区| 久久精品国内一区二区三区 | 亚洲一区中文日韩| 高清国产午夜精品久久久久久| 日韩欧美精品在线视频| 亚洲福利一区二区三区| 91片在线免费观看| 最新中文字幕一区二区三区| 国产成人av一区二区| 日韩一区二区免费视频| 亚洲在线观看免费| 欧美在线观看你懂的| 亚洲欧美日韩中文字幕一区二区三区 | 国产精品丝袜一区| 成人福利电影精品一区二区在线观看| 欧美一区二区免费| 亚洲动漫第一页| 亚洲乱码中文字幕| 日本一区二区电影| 婷婷久久综合九色综合绿巨人| 久久国产精品99久久人人澡| 欧美精品久久99久久在免费线 | 欧美亚洲高清一区二区三区不卡| 国产精品久久久久一区| 成人自拍视频在线观看| 国产精品久久久久影院| 成人av在线看| 国产精品大尺度| 91色视频在线| 亚洲成a人片在线不卡一二三区| 在线一区二区三区| 日本亚洲三级在线| 欧美不卡一区二区| 国产精品66部| 亚洲男人天堂av| 欧美日韩国产在线播放网站| 欧美aaa在线| 国产欧美一区视频| 色呦呦国产精品| 日韩高清在线一区| 久久久一区二区三区捆绑**| av在线不卡网| 五月婷婷综合在线| 精品久久久久久无| 成人免费看视频| 一区二区三区中文免费| 91精品国产日韩91久久久久久| 激情偷乱视频一区二区三区| 国产精品理论片| 欧美性受极品xxxx喷水| 久久精品国产精品亚洲红杏| 国产精品看片你懂得| 制服视频三区第一页精品| 国产99久久久国产精品免费看| 亚洲精品大片www| 欧美变态凌虐bdsm| 成人激情动漫在线观看| 亚洲电影在线播放| 欧美成人a在线| 欧美日韩一区二区在线观看| 国产一区二区在线观看免费| 亚洲欧美色一区| 亚洲精品一区二区三区四区高清| 91美女片黄在线| 国产成人无遮挡在线视频| 亚洲第一二三四区| 国产精品久久久久精k8| 7777精品伊人久久久大香线蕉的 | 国产精品视频观看| 91丨九色丨尤物| 亚洲电影在线免费观看| 日韩精品专区在线影院重磅| 黄网站免费久久| 本田岬高潮一区二区三区| 午夜精品久久久久久久99水蜜桃| 欧美日韩国产bt| 一本色道久久综合狠狠躁的推荐| 日韩电影一二三区| 天天综合天天做天天综合| 五月天精品一区二区三区| 亚洲人成网站色在线观看| 久久综合九色综合欧美98| 久久精品免视看| 国产福利一区在线观看| 婷婷亚洲久悠悠色悠在线播放 | 亚洲精品福利视频网站| 国产精品久99| 国产精品天天看| 国产亚洲一区二区三区四区| 欧美刺激脚交jootjob| 欧美精品v日韩精品v韩国精品v| 欧美在线不卡一区| 欧美视频一区二区在线观看| 欧美综合久久久| 色婷婷久久久综合中文字幕| 91香蕉视频在线| 日本韩国欧美在线| 欧美午夜影院一区| 欧美另类久久久品| 91精品国产综合久久福利软件 | 欧美日韩亚洲另类| 欧美性猛交xxxx乱大交退制版| 色老汉一区二区三区| 在线精品亚洲一区二区不卡| 欧洲人成人精品| 欧美人牲a欧美精品| 日韩西西人体444www| 久久综合久色欧美综合狠狠| 久久久精品人体av艺术| 国产欧美日韩视频一区二区| 1000部国产精品成人观看| 伊人一区二区三区| 亚洲国产日韩av| 国产一区二区三区在线观看免费 | a级高清视频欧美日韩| 色综合久久66| 欧美日韩黄视频| 久久久午夜精品| 国产精品久久久久久久久久久免费看 | 国产精品久久久久婷婷二区次| 国产精品久久久久aaaa樱花| 亚洲综合成人在线| 美洲天堂一区二卡三卡四卡视频| 国产精品乡下勾搭老头1| 91污片在线观看| 日韩一区二区不卡| 中文字幕欧美激情| 午夜电影一区二区三区| 国产美女精品在线| 欧美在线视频日韩| 久久久高清一区二区三区| 亚洲欧美激情在线| 精品一区二区三区久久| 91蜜桃视频在线| 精品国产91洋老外米糕| 一区精品在线播放| 蜜桃精品视频在线| 成人高清视频在线| 欧美成人官网二区| 一区二区三区成人| 国产盗摄女厕一区二区三区|