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

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

?? os_sem.c

?? ucos porting to arm946
?? C
?? 第 1 頁 / 共 2 頁
字號(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:
*

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
六月丁香婷婷久久| 欧美三日本三级三级在线播放| 欧美精品精品一区| 香蕉加勒比综合久久| 91精品综合久久久久久| 日本系列欧美系列| 国产夜色精品一区二区av| 国产在线不卡视频| 国产精品不卡在线| 欧美日韩国产小视频| 精品系列免费在线观看| 黑人巨大精品欧美一区| 国产寡妇亲子伦一区二区| 日本一区二区三区视频视频| 成人美女视频在线观看18| 亚洲欧美日韩在线不卡| 欧美一级黄色大片| 成人黄色小视频| 一区二区久久久久久| 欧美精品自拍偷拍| 国产老肥熟一区二区三区| 亚洲美女少妇撒尿| 欧美成人精品福利| 白白色 亚洲乱淫| 日本美女视频一区二区| 国产午夜亚洲精品理论片色戒| 91一区二区在线观看| 午夜精品福利一区二区蜜股av| 久久久久久毛片| 日本韩国欧美三级| 国产精品亚洲一区二区三区在线| 亚洲欧美激情在线| 日韩亚洲欧美在线| 91网址在线看| 中文欧美字幕免费| 色综合久久88色综合天天| 日韩va亚洲va欧美va久久| 日本一区二区视频在线| 69p69国产精品| 91视频免费看| 韩国中文字幕2020精品| 夜夜精品视频一区二区| 久久精品亚洲乱码伦伦中文| 欧美三级三级三级爽爽爽| 国产一区二区精品久久91| 亚洲国产一区在线观看| 中国av一区二区三区| 日韩三级免费观看| 欧洲日韩一区二区三区| 欧美伊人久久久久久久久影院 | 亚洲最色的网站| 26uuu亚洲综合色| 欧美日韩国产精品成人| 国产精品一二三区在线| 精品噜噜噜噜久久久久久久久试看| 91老师片黄在线观看| 精品一区二区三区的国产在线播放 | 欧美无砖专区一中文字| 国产盗摄女厕一区二区三区| 另类综合日韩欧美亚洲| 奇米一区二区三区| 日韩二区三区在线观看| 亚洲一区在线电影| 一级精品视频在线观看宜春院 | 国产精品污www在线观看| 91精品国产综合久久小美女| 欧美性猛交xxxxxx富婆| 97se亚洲国产综合自在线观| 成人影视亚洲图片在线| 狠狠色丁香久久婷婷综| 奇米影视7777精品一区二区| 石原莉奈一区二区三区在线观看| 在线精品视频免费观看| 在线播放91灌醉迷j高跟美女 | 欧美无人高清视频在线观看| 成人h动漫精品一区二区| 成人三级在线视频| 成人丝袜高跟foot| 国产成人99久久亚洲综合精品| 国产一区二区女| 国产精品影视网| 懂色av一区二区三区蜜臀| 国产一区二区三区日韩| 国产成a人亚洲精| av一区二区三区黑人| 久久视频一区二区| 精品福利av导航| 国产亚洲成年网址在线观看| 国产视频一区在线观看| 国产欧美日韩精品一区| 国产精品成人在线观看| 一区二区三区美女视频| 午夜久久电影网| 国产制服丝袜一区| 99国内精品久久| 欧美日韩在线不卡| 欧美电影免费观看高清完整版 | 三级亚洲高清视频| 日韩av在线发布| 精品一区二区三区视频| 国产一区二区看久久| jvid福利写真一区二区三区| 欧洲精品一区二区三区在线观看| 3d成人动漫网站| 2023国产精华国产精品| 免费成人在线视频观看| 日韩和的一区二区| 亚洲va欧美va天堂v国产综合| 日本中文字幕一区二区视频| 国产九色sp调教91| 色婷婷久久久久swag精品| 日韩手机在线导航| 亚洲视频免费在线观看| 五月天激情小说综合| 国产成人8x视频一区二区| 在线一区二区三区四区五区| 日韩三区在线观看| 亚洲视频狠狠干| 久久99精品国产麻豆不卡| 成人av在线影院| 日韩欧美在线综合网| 中文字幕一区二区三区在线观看 | 99久久精品国产精品久久| 欧美日韩国产一级片| 久久免费看少妇高潮| 国产精品久久久久影院亚瑟| 偷窥少妇高潮呻吟av久久免费| 国产一区二区在线影院| 日本韩国精品一区二区在线观看| 精品动漫一区二区三区在线观看| 亚洲蜜桃精久久久久久久| 韩国欧美一区二区| 欧美日韩一区二区在线视频| 欧美国产精品劲爆| 蜜桃视频在线观看一区二区| 在线观看一区二区视频| 国产精品午夜在线观看| 激情六月婷婷综合| 欧美日本乱大交xxxxx| 日韩美女视频一区二区| 国产美女av一区二区三区| 欧美一区二区日韩| 亚洲国产精品人人做人人爽| 99精品偷自拍| 日本一区二区三区高清不卡| 美日韩黄色大片| 91精品国产高清一区二区三区 | 欧美精品丝袜中出| 国产精品久久久久久户外露出| 韩日欧美一区二区三区| 欧美一级xxx| 青青草国产精品亚洲专区无| 欧美人妖巨大在线| 性久久久久久久久| 欧美日韩和欧美的一区二区| 一区二区三区免费网站| 日本电影亚洲天堂一区| 亚洲精选免费视频| 色综合久久88色综合天天免费| 日本一区二区三区久久久久久久久不 | 另类欧美日韩国产在线| aaa欧美大片| 国产精品不卡一区| jlzzjlzz欧美大全| 中文字幕一区二区三区四区不卡 | 97久久久精品综合88久久| 国产片一区二区三区| 国产剧情一区二区| 久久精品一区二区| 成人精品一区二区三区四区| 国产精品视频第一区| 99re这里只有精品6| 亚洲色图欧洲色图| 在线视频你懂得一区二区三区| 亚洲一区二区影院| 欧美日韩你懂的| 欧美bbbbb| 国产亚洲美州欧州综合国| 不卡在线观看av| 曰韩精品一区二区| 精品国产精品一区二区夜夜嗨| 国产在线不卡一区| 国产精品人成在线观看免费| 色综合久久久久网| 香港成人在线视频| 欧美成人一区二区三区| 岛国精品在线观看| 一区二区三区日韩精品视频| 欧美丰满嫩嫩电影| 精品一区二区三区在线观看| 欧美国产一区在线| 色老汉一区二区三区| 日韩vs国产vs欧美| 国产三级欧美三级日产三级99| 99久久99久久精品国产片果冻| 午夜欧美2019年伦理| 久久欧美一区二区| 欧美午夜电影网| 国产在线精品一区二区三区不卡| 中文字幕一区二区三区色视频|