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

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

?? os_sem.c

?? 基于ARM的嵌入式代碼
?? 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:
*

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影免费提供在线观看| 99久久婷婷国产综合精品电影 | 国产成人免费视频一区| 精品区一区二区| 毛片不卡一区二区| 国产亚洲欧美在线| av一区二区三区黑人| 亚洲日本成人在线观看| 欧美日韩一区小说| 免费人成网站在线观看欧美高清| 日韩限制级电影在线观看| 毛片不卡一区二区| 国产视频在线观看一区二区三区 | 国产在线精品一区在线观看麻豆| 欧美成人一区二区三区片免费| 国产一区二三区好的| 国产欧美一区二区在线| 91亚洲资源网| 蜜臀av亚洲一区中文字幕| 亚洲国产高清在线观看视频| 色诱视频网站一区| 久久99久久精品| 亚洲视频狠狠干| 91精品国产免费久久综合| 高清视频一区二区| 亚洲二区在线观看| 久久久久久综合| 91福利在线导航| 韩国精品在线观看| 亚洲国产综合91精品麻豆| 精品国产1区二区| 91网页版在线| 国内精品国产成人国产三级粉色| 亚洲色图一区二区三区| 精品免费日韩av| 欧美午夜片在线观看| 国产成人综合精品三级| 天天色天天操综合| 中文字幕在线观看不卡| 91精品国产乱码久久蜜臀| av中文字幕亚洲| 久久99精品国产91久久来源 | 亚洲小少妇裸体bbw| 亚洲久本草在线中文字幕| 欧美一级欧美一级在线播放| www.色综合.com| 极品瑜伽女神91| 日韩中文字幕一区二区三区| 欧美激情综合在线| 欧美一级片在线看| 欧美日韩在线播放三区四区| 成人综合婷婷国产精品久久蜜臀 | 99天天综合性| 欧美一区午夜视频在线观看| 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美日韩国产经典色站一区二区三区 | 成人久久久精品乱码一区二区三区 | 日韩精品一二三| 一区二区三区四区中文字幕| 中文字幕av一区二区三区高| 精品国产精品网麻豆系列| 777奇米成人网| 欧洲一区二区三区在线| 99久久精品久久久久久清纯| 国产成人综合亚洲网站| 韩国一区二区视频| 久久精品999| 日本美女一区二区三区视频| 亚洲伊人色欲综合网| 一区二区视频免费在线观看| 国产精品电影一区二区| 中文一区一区三区高中清不卡| 久久亚洲影视婷婷| 精品国产乱码久久久久久图片 | 欧美精品一区二区三区蜜桃| 日韩精品最新网址| 精品少妇一区二区三区视频免付费| 欧美日韩电影一区| 欧美色国产精品| 欧美日本高清视频在线观看| 欧美二区在线观看| 亚洲国产精品二十页| 久久精品免视看| 中文字幕av一区二区三区| 国产精品美女久久久久av爽李琼| 国产欧美一区二区在线| 国产精品视频一二| 亚洲日本在线a| 亚洲国产综合91精品麻豆| 午夜亚洲福利老司机| 视频在线在亚洲| 精品一区二区三区影院在线午夜 | 国产精品私人影院| 亚洲欧美日韩国产综合| 一区二区免费看| 午夜激情综合网| 久久91精品国产91久久小草| 国产精品亚洲综合一区在线观看| 成人性生交大片免费看视频在线| 91丨九色丨黑人外教| 欧美日韩一区小说| 26uuu国产电影一区二区| 国产丝袜在线精品| 一区二区三区四区在线播放 | 美女在线观看视频一区二区| 国产一区二区三区免费观看| 97久久超碰国产精品| 欧美日韩精品是欧美日韩精品| 精品剧情在线观看| 欧美国产综合一区二区| 亚洲午夜视频在线观看| 精品一区二区三区视频在线观看| 99在线精品一区二区三区| 亚洲国产精品一区二区久久恐怖片 | 奇米在线7777在线精品| 三级精品在线观看| 天天综合色天天综合色h| 激情文学综合插| 91浏览器在线视频| 日韩欧美一区在线| 亚洲青青青在线视频| 中文字幕乱码一区二区免费| 国产精品久久久久久久久动漫| 亚洲成人一区二区在线观看| 久久精品国产一区二区三| caoporn国产精品| 日韩一区二区电影| 国产精品久久夜| 亚洲成av人片一区二区三区| 国产精品综合二区| 在线观看视频91| 久久新电视剧免费观看| 亚洲午夜久久久久久久久电影网| 韩国成人福利片在线播放| 色婷婷综合久久久久中文一区二区 | 亚洲色图在线播放| 国内一区二区在线| 欧美三级一区二区| 中文字幕一区视频| 国产一区二区三区在线观看免费视频 | 欧美日韩在线观看一区二区 | 亚洲国产一区二区视频| 国产成人在线电影| 欧美电影免费观看高清完整版在线观看 | 国产一区二区三区免费播放| 欧美日韩久久久| 亚洲色图丝袜美腿| 成人性生交大合| 26uuu另类欧美亚洲曰本| 日韩精品每日更新| 欧美视频一区在线| 一区二区三区日韩精品视频| av在线综合网| 中文字幕一区在线观看| 成人精品视频一区| 中文字幕免费观看一区| 国产成a人亚洲精品| 国产亚洲综合在线| 国内精品自线一区二区三区视频| 欧美精品久久天天躁| 午夜av区久久| 欧美日韩成人综合天天影院 | 免费观看在线综合色| 欧美日韩国产另类不卡| 午夜不卡av在线| 欧美精品 日韩| 日本亚洲一区二区| 欧美疯狂做受xxxx富婆| 午夜电影久久久| 欧美一级黄色大片| 久久电影国产免费久久电影| 精品国产一区二区在线观看| 久久精品国产秦先生| 日韩一区二区三区视频在线观看| 日本va欧美va欧美va精品| 日韩欧美你懂的| 美日韩一级片在线观看| 久久夜色精品一区| 懂色一区二区三区免费观看| 亚洲欧洲精品一区二区三区| 在线一区二区三区四区五区| 亚洲国产一区视频| 欧美精品日日鲁夜夜添| 激情五月婷婷综合| 国产精品热久久久久夜色精品三区 | 日本精品视频一区二区三区| 亚洲自拍偷拍九九九| 欧美人与性动xxxx| 紧缚奴在线一区二区三区| 亚洲国产精品精华液ab| 91蝌蚪国产九色| 免费成人在线影院| 欧美国产一区二区| 91热门视频在线观看| 亚洲国产色一区| 精品福利在线导航| aaa亚洲精品| 亚洲在线视频免费观看| 日韩欧美电影一区| 97精品久久久久中文字幕|