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

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

?? os_sem.c

?? protues仿真ARM ARM的I2C
?? 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
*********************************************************************************************************
*/

#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)
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;
#endif    
    INT16U     cnt;


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


    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)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    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    */
                 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  */
             }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合精品久久| 日韩一区在线看| 一道本成人在线| 精品一区二区三区香蕉蜜桃| 国产精品久久久久久久午夜片| 欧美精品日日鲁夜夜添| 成人aa视频在线观看| 精品在线一区二区三区| 午夜精品福利在线| 亚洲品质自拍视频| 日本一区二区综合亚洲| 日韩一区二区三区在线观看| 色视频成人在线观看免| 国产精品18久久久久久久久| 日韩影院在线观看| 亚洲男同性恋视频| 欧美激情在线一区二区三区| 日韩欧美亚洲另类制服综合在线| 在线观看区一区二| k8久久久一区二区三区| 国产激情一区二区三区| 久久激五月天综合精品| 视频在线观看一区二区三区| 亚洲综合一区二区| 亚洲精品久久久久久国产精华液| 欧美国产亚洲另类动漫| 欧美精品一区二区精品网| 欧美一区二区三区日韩| 欧美一区二区日韩一区二区| 欧美午夜精品一区二区蜜桃| 色婷婷国产精品久久包臀| 不卡的av在线播放| 99re热这里只有精品免费视频 | 色哟哟精品一区| 99综合影院在线| 99精品国产热久久91蜜凸| 亚洲精品视频自拍| 国产调教视频一区| 欧美私模裸体表演在线观看| 狠狠色丁香久久婷婷综| 一区二区三区免费在线观看| 久久夜色精品国产欧美乱极品| 成人亚洲精品久久久久软件| 免费欧美高清视频| 一区二区三区欧美视频| 国产亚洲精品bt天堂精选| 这里是久久伊人| 91在线精品秘密一区二区| 激情综合网av| 青青国产91久久久久久| 一区二区三区四区视频精品免费 | 久久久久国产精品麻豆| 日本韩国一区二区| 91在线一区二区三区| 国产一区不卡在线| 中文字幕中文字幕在线一区 | 国产亚洲欧美日韩在线一区| 欧美国产日韩精品免费观看| 国内精品嫩模私拍在线| 一区二区三区自拍| 亚洲精品一二三四区| 性做久久久久久久免费看| 青青草视频一区| 激情综合网天天干| av在线不卡免费看| 欧洲国内综合视频| 日韩三级电影网址| 欧美激情中文不卡| 亚洲国产精品嫩草影院| 捆绑紧缚一区二区三区视频 | 国产精品99久久久| 97超碰欧美中文字幕| 欧美日韩一区不卡| 久久久另类综合| 亚洲精品中文在线影院| 久久精品国产免费看久久精品| 国产99久久久国产精品潘金网站| 91一区一区三区| 欧美一区二区精美| 国产精品久99| 亚洲成人一区二区在线观看| 精品亚洲aⅴ乱码一区二区三区| 成人黄色在线网站| 4438亚洲最大| 亚洲欧洲99久久| 免费在线观看视频一区| 99久久99久久精品国产片果冻| 欧美一区二区三区播放老司机| 日本一区二区三区国色天香 | 欧美电视剧免费观看| 国产精品福利av| 久久精品国产秦先生| 在线一区二区三区做爰视频网站| 日韩一区二区免费在线观看| 亚洲欧美日韩人成在线播放| 精品综合免费视频观看| 欧美日韩国产首页在线观看| 国产日产亚洲精品系列| 日本亚洲天堂网| 色综合久久综合网欧美综合网 | 亚洲色图欧洲色图| 国产美女娇喘av呻吟久久| 欧美日本在线一区| 亚洲精品日韩综合观看成人91| 国产乱人伦精品一区二区在线观看| 欧美亚洲另类激情小说| 国产精品国产a级| 国产一区二区三区免费| 欧美一区二区在线免费播放| 亚洲免费观看高清完整版在线观看熊| 国产一区二区三区四区在线观看| 欧美日韩精品免费观看视频| 亚洲精品高清在线| 99免费精品在线| 国产精品午夜在线观看| 国内一区二区视频| 日韩欧美国产系列| 日韩影院精彩在线| 欧美日本韩国一区| 亚洲最大的成人av| 91久久精品日日躁夜夜躁欧美| 国产精品久久久久天堂| 国产福利一区在线| 久久久亚洲精品一区二区三区| 日本在线观看不卡视频| 91精品国产综合久久久久| 亚洲午夜成aⅴ人片| 在线观看日韩电影| 亚洲国产精品欧美一二99| 欧美主播一区二区三区| 亚洲另类中文字| 91黄色在线观看| 亚洲综合精品自拍| 欧美日韩视频专区在线播放| 一区二区三区精品在线观看| 日本电影欧美片| 亚洲综合小说图片| 欧美日韩高清一区二区| 午夜国产精品影院在线观看| 91 com成人网| 蜜臀av性久久久久蜜臀aⅴ | 一区二区三区不卡视频| 在线观看视频一区| 午夜电影一区二区| 日韩欧美中文字幕公布| 国产麻豆一精品一av一免费| 国产婷婷色一区二区三区四区| 国产成人a级片| 亚洲欧洲99久久| 欧美色爱综合网| 美女视频免费一区| 国产欧美日韩久久| 99精品视频中文字幕| 夜夜亚洲天天久久| 5月丁香婷婷综合| 韩日av一区二区| 国产精品短视频| 欧美猛男gaygay网站| 蜜桃av一区二区三区| 久久久精品tv| 91亚洲精品久久久蜜桃| 五月天一区二区| 欧美精品一区在线观看| 成人91在线观看| 亚洲成人精品在线观看| 日韩欧美国产综合| 不卡av在线免费观看| 亚洲h在线观看| 久久久99精品久久| 日本久久电影网| 九九久久精品视频| 亚洲天堂精品在线观看| 欧美日本在线观看| 丰满少妇久久久久久久| 一区二区高清在线| 精品sm在线观看| 一本色道a无线码一区v| 免费人成在线不卡| 136国产福利精品导航| 欧美一区二区三区不卡| 99re成人精品视频| 精品亚洲免费视频| 一区二区视频免费在线观看| 精品国精品国产| 欧美午夜精品久久久久久孕妇 | 久久国产精品99久久人人澡| 亚洲视频在线观看三级| 日韩欧美一二区| 色婷婷精品久久二区二区蜜臂av| 激情五月激情综合网| 亚洲一区二区在线免费观看视频| 欧美tk丨vk视频| 欧美性感一类影片在线播放| 国产一区欧美一区| 日韩中文字幕不卡| 亚洲精品视频在线看| 国产情人综合久久777777| 91精品国产一区二区三区香蕉| av亚洲精华国产精华精华 | 91在线视频观看|