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

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

?? os_sem.c

?? uCOS-II 在ARM7上的移植源代碼,我在up-netarm3000已經測試
?? 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一区二区三区免费野_久草精品视频
在线观看国产一区二区| 韩国一区二区三区| 国产清纯白嫩初高生在线观看91| 在线亚洲高清视频| 91论坛在线播放| 成人午夜激情在线| 国产不卡高清在线观看视频| 国内精品第一页| 激情六月婷婷久久| 激情六月婷婷久久| 国产一区二区三区在线观看免费 | av不卡免费在线观看| 久久国产夜色精品鲁鲁99| 亚洲成国产人片在线观看| 亚洲精品国产一区二区三区四区在线| 中文字幕不卡在线| 中文字幕一区二区三区蜜月| 国产精品丝袜一区| 亚洲蜜臀av乱码久久精品蜜桃| 国产精品每日更新| 亚洲视频免费在线观看| 亚洲三级在线免费观看| 一区二区三区欧美日韩| 亚洲国产你懂的| 毛片一区二区三区| 国产精品一级片| 色哦色哦哦色天天综合| 欧美日韩成人高清| 久久久精品影视| 日韩码欧中文字| 日韩影院免费视频| 国产乱码精品一区二区三区忘忧草 | 亚洲网友自拍偷拍| 日韩成人一区二区三区在线观看| 日本色综合中文字幕| www.亚洲色图.com| 91一区二区在线观看| 欧美三日本三级三级在线播放| 欧美日韩国产一区| 久久久噜噜噜久久人人看| 亚洲免费观看在线观看| 人禽交欧美网站| 成人av资源网站| 欧美年轻男男videosbes| 久久婷婷一区二区三区| 亚洲三级在线免费观看| 激情综合色丁香一区二区| 99久久99久久久精品齐齐| 91精品婷婷国产综合久久 | 日本中文在线一区| 粉嫩欧美一区二区三区高清影视| 欧美性一二三区| 国产色一区二区| 天堂久久久久va久久久久| 成人综合在线视频| 精品国产污污免费网站入口| 亚洲精品欧美二区三区中文字幕| 精品午夜一区二区三区在线观看| 91日韩一区二区三区| 国产日产欧美一区二区三区| 五月综合激情婷婷六月色窝| 99视频有精品| 亚洲国产精品黑人久久久| 蜜臀av亚洲一区中文字幕| 91视频在线观看免费| 欧美激情一区二区三区| 久久国产精品99精品国产| 欧美午夜片在线观看| 亚洲人午夜精品天堂一二香蕉| 国产伦理精品不卡| 日韩欧美一二三四区| 午夜电影久久久| 欧美日韩免费在线视频| 亚洲天天做日日做天天谢日日欢| 国产成人亚洲综合a∨婷婷| 日韩色在线观看| 秋霞电影网一区二区| 欧美精品一级二级三级| 午夜精品福利久久久| 久久久夜色精品亚洲| 麻豆91小视频| 欧美电影免费观看完整版| 日本视频中文字幕一区二区三区| 欧美精品黑人性xxxx| 亚洲www啪成人一区二区麻豆| 在线免费观看日本欧美| 夜夜操天天操亚洲| 欧美日韩国产色站一区二区三区| 亚洲福利视频三区| 欧美日韩精品欧美日韩精品一综合| 亚洲一区二区综合| 欧美三级欧美一级| 日本vs亚洲vs韩国一区三区二区| 制服丝袜av成人在线看| 日本va欧美va欧美va精品| 精品三级在线看| 成人免费视频一区二区| 亚洲特黄一级片| 欧美日韩国产成人在线91| 日韩国产欧美在线视频| 久久综合精品国产一区二区三区| 国产一区二区福利视频| 中文字幕一区二区在线观看| 91行情网站电视在线观看高清版| 亚洲一区二区三区四区不卡| 91精品国产色综合久久久蜜香臀| 免费成人av在线播放| 精品福利在线导航| jlzzjlzz欧美大全| 婷婷丁香久久五月婷婷| 久久久亚洲精品石原莉奈| 99久久综合狠狠综合久久| 午夜激情一区二区| 国产清纯美女被跳蛋高潮一区二区久久w | 亚洲少妇中出一区| 欧美精品粉嫩高潮一区二区| 裸体一区二区三区| 中文字幕一区二区三区乱码在线| 欧美日韩国产成人在线免费| 国产成人自拍在线| 亚洲va天堂va国产va久| 久久久蜜桃精品| 欧美日韩久久久久久| 国产成人精品三级麻豆| 亚洲第一综合色| 国产欧美一区二区三区鸳鸯浴 | 亚洲激情图片一区| 中文字幕日本乱码精品影院| 欧美日韩亚洲综合| 国产aⅴ综合色| 日本欧美加勒比视频| 亚洲欧美影音先锋| 欧美mv日韩mv国产| 91福利国产精品| 国产不卡视频一区二区三区| 日韩中文字幕区一区有砖一区| 国产精品毛片久久久久久| 在线播放/欧美激情| 福利91精品一区二区三区| 日本特黄久久久高潮| 亚洲欧美国产三级| 日本一区二区三区在线不卡 | 亚洲成人av中文| 最新中文字幕一区二区三区| 久久婷婷国产综合精品青草| 欧美日韩精品免费| 色8久久人人97超碰香蕉987| 国产成人小视频| 国产黑丝在线一区二区三区| 日韩av在线免费观看不卡| 亚洲国产精品久久人人爱| 亚洲美女在线国产| 中文字幕佐山爱一区二区免费| 久久精品一区二区三区不卡| 精品福利视频一区二区三区| 日韩一级二级三级精品视频| 欧美一区欧美二区| 欧美一区二区三区的| 欧美高清视频不卡网| 69久久夜色精品国产69蝌蚪网| 欧美日韩在线播放一区| 欧美日韩中文字幕一区二区| 欧美午夜理伦三级在线观看| 欧美日韩中文字幕精品| 欧美视频在线观看一区二区| 欧美日韩一区二区三区在线看| 在线观看精品一区| 欧美美女bb生活片| 欧美大片顶级少妇| 伊人婷婷欧美激情| 亚洲最大成人综合| 天使萌一区二区三区免费观看| 午夜精品久久久| 精品一区二区三区在线播放| 韩国欧美一区二区| 本田岬高潮一区二区三区| 91麻豆产精品久久久久久| 精品视频999| 欧美电视剧在线看免费| 久久久精品免费免费| 亚洲欧美综合在线精品| 亚洲最新在线观看| 久久69国产一区二区蜜臀 | www日韩大片| 中文字幕日本不卡| 日本三级亚洲精品| 国产美女一区二区三区| 不卡在线观看av| 在线精品视频一区二区三四 | 欧美日本一区二区三区四区| 欧美一区二区精品| 欧美国产欧美综合| 亚洲第四色夜色| 国产精品88av| 欧美在线免费播放| 国产亚洲美州欧州综合国| 亚洲激情图片小说视频| 九一九一国产精品| 在线免费观看日本一区| 久久久蜜桃精品|