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

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

?? os_sem.c

?? ucosII for ARM4510B
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2001, 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)
{
    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)
{
    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                      */
        OS_EventWaitListInit(pevent);
    }
    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 (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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
9191精品国产综合久久久久久| 国产精品自在欧美一区| 人人狠狠综合久久亚洲| 国产成人日日夜夜| 制服.丝袜.亚洲.中文.综合| 亚洲国产成人私人影院tom| 日韩精品每日更新| 欧美在线观看禁18| 国产精品视频观看| 精品夜夜嗨av一区二区三区| 欧美日韩国产色站一区二区三区| 中文字幕精品—区二区四季| 极品美女销魂一区二区三区 | 欧美三级韩国三级日本一级| aa级大片欧美| 欧美色爱综合网| 国产日韩欧美在线一区| 美女性感视频久久| 欧美在线视频日韩| 国产精品嫩草影院av蜜臀| 精品中文字幕一区二区小辣椒| 欧美性受xxxx| 亚洲乱码一区二区三区在线观看| 国产高清在线精品| 国产无人区一区二区三区| 久久精品国产99久久6| 8x8x8国产精品| 国产精品一区2区| 亚洲欧美另类小说视频| 午夜精品一区二区三区免费视频| 99久久精品国产导航| 亚洲国产精品成人综合| 国产69精品久久久久777| 久久久亚洲午夜电影| 国产成人综合精品三级| 国产亚洲欧美日韩日本| 成人午夜视频在线观看| 国产精品卡一卡二卡三| 91婷婷韩国欧美一区二区| 综合色天天鬼久久鬼色| 日本道色综合久久| 丝袜诱惑制服诱惑色一区在线观看| 欧美欧美欧美欧美首页| 丝袜美腿亚洲综合| 精品国产一区a| 国产在线观看免费一区| 欧美高清在线一区| 91麻豆免费在线观看| 亚洲一本大道在线| 日韩你懂的在线播放| 国产福利一区在线| 亚洲精品日韩一| 91精品国产综合久久婷婷香蕉| 蜜臀av国产精品久久久久| 日韩一级高清毛片| 欧美日韩一级大片网址| 午夜欧美电影在线观看| 日韩欧美一级二级| 成人晚上爱看视频| 亚洲v精品v日韩v欧美v专区 | 一区二区三区四区在线| 欧美午夜精品理论片a级按摩| 免费在线观看日韩欧美| 日本一区二区三区dvd视频在线| 91啪九色porn原创视频在线观看| 午夜激情一区二区三区| 中文字幕欧美日本乱码一线二线| 在线中文字幕一区二区| 激情五月婷婷综合网| 亚洲视频一区在线观看| 日韩欧美中文一区二区| 91免费版在线| 韩国av一区二区| 夜色激情一区二区| 国产片一区二区三区| 欧美性做爰猛烈叫床潮| 成人国产精品免费| 奇米777欧美一区二区| 亚洲人123区| 久久人人爽人人爽| 这里只有精品视频在线观看| av网站免费线看精品| 蜜臀av一区二区三区| 一区二区三区在线视频免费观看| 久久综合久久久久88| 欧美日免费三级在线| aaa亚洲精品| 国产成人精品午夜视频免费| 麻豆国产精品官网| 国产真实精品久久二三区| 亚洲男人的天堂一区二区| 欧美va亚洲va| 欧美精品视频www在线观看| 北条麻妃一区二区三区| 韩国成人精品a∨在线观看| 天堂成人免费av电影一区| 亚洲人成在线观看一区二区| 久久久蜜臀国产一区二区| 日韩片之四级片| 欧美精品 国产精品| 91久久一区二区| 色婷婷一区二区| 91影院在线免费观看| 波多野结衣在线一区| 国产乱人伦偷精品视频不卡| 人妖欧美一区二区| 欧美96一区二区免费视频| 亚洲成人av电影| 香蕉加勒比综合久久| 亚洲国产成人高清精品| 亚洲一区二区三区四区在线| 亚洲精品一二三区| 一区二区三区在线观看欧美| 狠狠色丁香久久婷婷综合_中 | 国产清纯白嫩初高生在线观看91| 欧美日韩一区二区三区视频| 色欧美日韩亚洲| 色老汉一区二区三区| 一本一道久久a久久精品综合蜜臀| av在线一区二区| 99视频超级精品| 91麻豆免费观看| 欧美视频一区二区三区在线观看| 欧美日韩在线直播| 7777精品伊人久久久大香线蕉| 欧美一区二区美女| 精品理论电影在线观看| 国产蜜臀av在线一区二区三区| 国产女人aaa级久久久级 | 91美女在线看| 欧美亚洲一区二区三区四区| 欧美麻豆精品久久久久久| 欧美一区二区性放荡片| 欧美日韩三级视频| 欧美伦理电影网| 欧美电影免费观看高清完整版在线观看 | 91精品国产福利在线观看| 日韩一区和二区| 国产片一区二区| 一区二区三区在线免费| 另类小说视频一区二区| 丰满白嫩尤物一区二区| 色菇凉天天综合网| 日韩区在线观看| 亚洲丝袜制服诱惑| 免费观看成人av| 99精品国产91久久久久久 | 爽好久久久欧美精品| 韩国理伦片一区二区三区在线播放| 国产a区久久久| 精品视频一区二区三区免费| 久久综合成人精品亚洲另类欧美 | 91尤物视频在线观看| 欧美伦理视频网站| 日本一区二区三区在线观看| 亚洲亚洲精品在线观看| 国产精品一区免费视频| 欧美日韩一区国产| 国产女人水真多18毛片18精品视频| 亚洲午夜一二三区视频| 国产河南妇女毛片精品久久久| 在线观看视频一区二区欧美日韩 | 91精品国产91久久综合桃花| 五月综合激情网| www.久久精品| 韩国毛片一区二区三区| 天天色综合天天| 处破女av一区二区| 3d动漫精品啪啪1区2区免费| 国产精品一区久久久久| 亚洲成人av一区二区三区| 丰满少妇在线播放bd日韩电影| 国产片一区二区| 成人动漫在线一区| 国产精品美女一区二区在线观看| 丁香桃色午夜亚洲一区二区三区| 亚洲国产精品成人综合色在线婷婷| 国产最新精品精品你懂的| 久久久精品欧美丰满| 国产精品一二三四| 国产精品国产精品国产专区不蜜 | 麻豆极品一区二区三区| 日韩欧美电影一区| 国内成人自拍视频| 欧美国产精品久久| 色欧美片视频在线观看 | 91精品在线观看入口| 蜜臀精品久久久久久蜜臀| 日韩一区二区免费高清| 国产在线精品一区二区| 国产精品美女久久久久aⅴ国产馆| 99久精品国产| 日日欢夜夜爽一区| 久久久久久久久伊人| 97国产一区二区| 午夜精品爽啪视频| 国产色产综合色产在线视频| 一本在线高清不卡dvd| 麻豆91精品91久久久的内涵| 国产午夜精品美女毛片视频|