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

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

?? os_sem.c

?? iar環境下移植ucos-ii到at91sam7s64
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2006, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.83
*********************************************************************************************************
*/

#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 = 0;
#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 = 0;
#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;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (err == (INT8U *)0) {                               /* Validate 'err'                           */
        return (pevent);
    }
    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);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore    */
        tasks_waiting = OS_TRUE;                           /* Yes                                      */
    } else {
        tasks_waiting = OS_FALSE;                          /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == OS_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;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err                   = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0) {             /* 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 == OS_TRUE) {               /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err                   = OS_NO_ERR;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *err                   = OS_ERR_INVALID_OPT;
             pevent_return          = pevent;
             break;
    }
    return (pevent_return);
}
#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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费观看在线综合| 欧美精品一二三区| 色94色欧美sute亚洲线路一ni| 欧美人动与zoxxxx乱| 欧美激情一二三区| 免费不卡在线观看| 在线亚洲一区二区| 国产欧美日产一区| 日韩激情在线观看| 欧美中文字幕亚洲一区二区va在线| 精品成人在线观看| 日韩国产在线一| 色综合天天综合给合国产| 亚洲精品在线观看视频| 五月天一区二区三区| 91麻豆高清视频| 中文字幕欧美国产| 狠狠色综合播放一区二区| 91精品国产一区二区三区蜜臀| 亚洲人精品一区| aa级大片欧美| 国产精品理伦片| 成人午夜在线播放| 久久美女艺术照精彩视频福利播放| 日韩vs国产vs欧美| 欧美一区二区三区在线电影| 亚洲综合小说图片| 欧美影院一区二区三区| 亚洲三级在线观看| 91视频观看视频| 亚洲欧洲精品天堂一级| 成人avav在线| 国产精品视频一二三区| 床上的激情91.| 国产精品女同一区二区三区| 国产凹凸在线观看一区二区| 欧美成人精品高清在线播放| 久久精品久久精品| 精品欧美乱码久久久久久| 六月婷婷色综合| 精品粉嫩aⅴ一区二区三区四区| 久久99精品久久只有精品| 日韩精品一区二区三区在线观看| 男人的j进女人的j一区| 日韩欧美一区二区不卡| 国内外精品视频| 亚洲国产电影在线观看| 成人精品免费看| 亚洲欧美日韩国产手机在线| 91久久一区二区| 五月婷婷色综合| 26uuu色噜噜精品一区二区| 韩国女主播成人在线观看| 国产欧美视频一区二区三区| av高清久久久| 偷拍亚洲欧洲综合| 精品国产乱子伦一区| 成人精品鲁一区一区二区| 亚洲欧美激情插 | 国产欧美日韩在线观看| 成人av网址在线观看| 亚洲综合免费观看高清完整版在线| 欧美午夜精品久久久久久超碰| 蜜桃av一区二区在线观看| 久久综合久久鬼色| 日本电影亚洲天堂一区| 久久福利资源站| 亚洲精品久久7777| 精品日产卡一卡二卡麻豆| 99精品欧美一区二区三区小说 | 欧美精品一区二区三区在线 | 国产精品羞羞答答xxdd| 1024成人网| 欧美日韩视频在线一区二区| 韩国精品一区二区| 亚洲午夜三级在线| 国产女同性恋一区二区| 欧美三级电影在线看| 国产精品 欧美精品| 亚洲香蕉伊在人在线观| 欧美国产1区2区| 91精品啪在线观看国产60岁| www.日本不卡| 国产尤物一区二区| 亚洲午夜精品久久久久久久久| 欧美精品一区二区三区四区| 在线观看中文字幕不卡| 国产成人丝袜美腿| 另类小说欧美激情| 亚洲超碰精品一区二区| 综合久久给合久久狠狠狠97色 | 国产精品资源在线看| 亚洲国产综合视频在线观看| 日本一区二区三区在线不卡| 欧美一区二区在线免费播放| av在线一区二区三区| 国产精品资源网站| 免费高清在线视频一区·| 亚洲国产一区二区三区青草影视| 国产精品蜜臀av| 中文乱码免费一区二区| 久久久精品免费免费| 欧美一级xxx| 6080国产精品一区二区| 欧美男男青年gay1069videost| 91麻豆123| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 在线不卡的av| 欧美日韩亚洲高清一区二区| 91影视在线播放| 成人18视频在线播放| 成人一区二区三区| 国产激情精品久久久第一区二区| 老司机精品视频线观看86| 日韩电影在线一区| 免费人成网站在线观看欧美高清| 日韩一区精品视频| 日产欧产美韩系列久久99| 亚洲国产精品一区二区www在线| 亚洲激情图片qvod| 一区二区三区精品在线| 亚洲综合视频在线观看| 一区二区国产盗摄色噜噜| 亚洲黄色小说网站| 一二三四区精品视频| 亚洲第一二三四区| 日韩精品午夜视频| 久久精品国产99国产| 国产一区二区精品在线观看| 国产福利91精品| 成人国产在线观看| 91麻豆精品在线观看| 欧美系列日韩一区| 51精品秘密在线观看| 欧美α欧美αv大片| 国产亚洲短视频| 老司机免费视频一区二区三区| 精品影视av免费| 粉嫩av亚洲一区二区图片| 91丝袜国产在线播放| 欧美吻胸吃奶大尺度电影 | 久久精品夜色噜噜亚洲a∨| 国产精品视频免费看| 一区二区三区欧美亚洲| 日韩av高清在线观看| 国产成人av影院| 久久嫩草精品久久久精品一| 1024精品合集| 免费人成精品欧美精品 | 久久久久久久综合色一本| 国产精品久久久久永久免费观看 | 91在线观看免费视频| 欧美精品在线观看播放| 久久嫩草精品久久久精品| 亚洲精选视频在线| 麻豆精品在线观看| 色综合亚洲欧洲| 欧美精品一区二区高清在线观看| 国产精品护士白丝一区av| 日韩成人精品在线观看| 成人99免费视频| 日韩欧美成人一区二区| 亚洲精品视频自拍| 国产综合色在线| 欧洲精品视频在线观看| 中文av一区特黄| 另类专区欧美蜜桃臀第一页| 色婷婷av一区二区三区软件| 精品国产乱码久久久久久久| 亚洲综合另类小说| 成人综合婷婷国产精品久久| 欧美精品三级在线观看| 亚洲人妖av一区二区| 国产高清不卡一区| 日韩午夜在线观看视频| 一区二区三区国产精华| 成人美女视频在线看| 精品人伦一区二区色婷婷| 午夜精品123| 91成人在线精品| 亚洲啪啪综合av一区二区三区| 狠狠狠色丁香婷婷综合激情| 欧美日韩成人在线一区| 亚洲黄色免费网站| 99热国产精品| 中文一区在线播放| 国产美女精品人人做人人爽| 91精品婷婷国产综合久久竹菊| 亚洲欧美国产高清| 91捆绑美女网站| 亚洲图片激情小说| 91在线无精精品入口| 中文字幕的久久| 成人a免费在线看| 中文字幕在线观看不卡视频| 欧美成人一区二区三区片免费| 中文字幕国产一区| 国产一区二区三区观看| 久久久亚洲精品一区二区三区| 亚洲午夜羞羞片|