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

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

?? ucos-ii_sem.c

?? 嵌入式實(shí)時(shí)操作系統(tǒng)UCOS-II中關(guān)于信號(hào)量的實(shí)現(xiàn)
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):


/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.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);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
#endif
    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                */
        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);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    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) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 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);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             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);
    }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆视频网站| 美腿丝袜亚洲三区| av成人动漫在线观看| 国产精品美女久久久久久2018| 国产成人在线免费观看| 中文字幕免费不卡| 97精品超碰一区二区三区| 亚洲精品一二三区| 欧美日韩精品三区| 久久丁香综合五月国产三级网站| 精品国产91久久久久久久妲己| 国产麻豆视频一区| 亚洲色图制服丝袜| 欧美精品欧美精品系列| 麻豆免费看一区二区三区| 久久一区二区三区四区| 99精品偷自拍| 亚洲高清免费在线| xnxx国产精品| 色一情一伦一子一伦一区| 香蕉av福利精品导航| 亚洲精品一区二区在线观看| 成人午夜电影网站| 日日夜夜免费精品| 国产欧美1区2区3区| 欧美三级电影网| 国产综合久久久久久鬼色| 亚洲三级视频在线观看| 3atv一区二区三区| 波多野结衣在线aⅴ中文字幕不卡| 亚洲综合在线免费观看| 精品国产一区二区三区久久影院 | 亚洲一线二线三线视频| 精品欧美黑人一区二区三区| 91麻豆精品一区二区三区| 日韩精品国产精品| 亚洲欧洲成人自拍| 久久婷婷综合激情| 欧美日韩国产精品自在自线| 东方aⅴ免费观看久久av| 日韩精品一卡二卡三卡四卡无卡| 国产精品久线观看视频| 日韩天堂在线观看| 色域天天综合网| 国产毛片一区二区| 免费看欧美女人艹b| 一区二区三区精品久久久| 欧美精品一区二区三区很污很色的 | 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲欧洲av在线| 久久久九九九九| 日韩小视频在线观看专区| 在线看不卡av| 972aa.com艺术欧美| 国产成人免费高清| 久久99深爱久久99精品| 日韩精品久久理论片| 亚洲va中文字幕| 亚洲激情第一区| 中文字幕的久久| 久久噜噜亚洲综合| 欧美xxxxx牲另类人与| 3d动漫精品啪啪| 欧美精品免费视频| 欧美日韩dvd在线观看| 一本到一区二区三区| 成人爽a毛片一区二区免费| 国产永久精品大片wwwapp | 国产一区二区成人久久免费影院| 日韩av电影天堂| 视频一区二区三区入口| 性做久久久久久久久| 亚洲精品国产无天堂网2021| 国产精品美女久久福利网站| 国产欧美一区二区精品秋霞影院| 26uuu久久综合| 久久免费看少妇高潮| 国产色产综合产在线视频| 久久精品水蜜桃av综合天堂| 久久天天做天天爱综合色| 久久亚洲捆绑美女| 欧美国产精品久久| 国产精品久久久久一区| 综合久久给合久久狠狠狠97色| 国产精品国产三级国产普通话99| 自拍偷拍欧美精品| 亚洲一区二区三区影院| 视频一区二区中文字幕| 精品一二三四区| 粉嫩嫩av羞羞动漫久久久| www.欧美.com| 欧美精品在线视频| 日韩欧美专区在线| 国产欧美精品一区| 一区二区三区高清| 午夜精品福利一区二区蜜股av | 日本一区二区三区四区| 国产精品国产三级国产三级人妇| 亚洲免费观看高清完整版在线观看 | 午夜精品福利久久久| 免费精品视频最新在线| 国产麻豆精品95视频| 91在线视频免费91| 欧美精品久久99久久在免费线 | 成人h动漫精品一区二| 91麻豆精品视频| 69精品人人人人| 久久精品欧美一区二区三区麻豆| 亚洲男人的天堂在线观看| 免费看欧美女人艹b| 丰满白嫩尤物一区二区| 欧美在线看片a免费观看| 欧美一级艳片视频免费观看| 国产性天天综合网| 一区二区国产盗摄色噜噜| 狠狠色综合播放一区二区| caoporen国产精品视频| 91精品国产91久久综合桃花| 日本一区二区不卡视频| 亚洲风情在线资源站| 国产经典欧美精品| 欧美疯狂性受xxxxx喷水图片| 国产色综合久久| 图片区小说区区亚洲影院| av成人免费在线| 久久综合精品国产一区二区三区| 一级做a爱片久久| 国内外成人在线| 欧美日韩国产大片| 国产精品久久久久四虎| 精品一区二区三区不卡| 欧美综合亚洲图片综合区| 国产日韩欧美在线一区| 蜜桃视频在线一区| 欧美中文字幕一区二区三区| 国产蜜臀97一区二区三区| 美女视频网站久久| 欧美日韩小视频| 亚洲日本电影在线| 高清不卡一二三区| 精品国产区一区| 美女视频网站黄色亚洲| 欧美色手机在线观看| 一色桃子久久精品亚洲| 国产一区二区三区不卡在线观看| 欧美精品自拍偷拍| 亚洲国产精品久久久久秋霞影院| 99精品久久只有精品| 国产人成一区二区三区影院| 精品一区二区三区久久| 日韩一区二区三区精品视频| 午夜久久久久久久久| 色综合激情五月| 亚洲裸体xxx| 99久久久国产精品| 中文字幕一区二区三区在线播放 | 激情综合五月天| 一区二区高清视频在线观看| www.66久久| 综合欧美一区二区三区| caoporm超碰国产精品| 国产精品久久免费看| 国产91精品在线观看| 久久久不卡网国产精品二区| 精品一区二区国语对白| 久久婷婷成人综合色| 国产精品一区二区在线观看网站| 精品久久人人做人人爰| 精品一区二区三区不卡| 久久婷婷色综合| 成人免费av网站| 亚洲欧美日韩人成在线播放| 一本久久精品一区二区| 亚洲国产日产av| 欧美精品久久久久久久多人混战 | 色婷婷亚洲精品| 亚洲一区二区在线播放相泽| 欧美一a一片一级一片| 婷婷夜色潮精品综合在线| 欧美一区二区三区免费| 国产一区二区三区四区五区入口| 久久婷婷综合激情| aaa亚洲精品| 香蕉加勒比综合久久| 欧美不卡一二三| 成人一区二区三区视频在线观看 | 成人免费视频视频在线观看免费 | 欧美日韩日本视频| 日韩电影在线免费看| 精品国产乱码久久久久久闺蜜| 国产成人午夜99999| 亚洲欧美视频在线观看视频| 欧美日韩在线观看一区二区 | 狠狠色狠狠色合久久伊人| 欧美激情一区二区三区四区| 色综合久久中文字幕| 日韩中文字幕91| 日本一区二区成人在线| 欧美日韩一区二区三区免费看| 蜜桃视频在线一区|