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

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

?? os_sem.c

?? ucos-ii+lpc123x proteus emulate
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日本乱大交xxxxx| 另类成人小视频在线| 亚洲成人av福利| 久久成人麻豆午夜电影| 成人天堂资源www在线| 欧美怡红院视频| 久久亚洲精精品中文字幕早川悠里| 久久久精品人体av艺术| 洋洋av久久久久久久一区| 久久97超碰色| 91在线国内视频| 日韩精品专区在线影院观看| 中文字幕在线一区二区三区| 日本成人在线视频网站| 99视频热这里只有精品免费| 欧美丰满高潮xxxx喷水动漫| 国产精品久久久久久久第一福利| 日韩激情一区二区| 成人精品视频一区二区三区尤物| 欧美久久一二三四区| 国产亚洲一区二区在线观看| 亚洲国产精品久久艾草纯爱| 国产成人av电影在线| 欧美日韩午夜影院| 国产精品沙发午睡系列990531| 首页国产欧美久久| 97久久精品人人澡人人爽| 精品对白一区国产伦| 亚洲成人激情av| 色综合天天综合网天天狠天天 | 日韩毛片精品高清免费| 另类小说综合欧美亚洲| 精品婷婷伊人一区三区三| 亚洲国产精品传媒在线观看| 麻豆91在线看| 欧美肥妇bbw| 夜夜操天天操亚洲| zzijzzij亚洲日本少妇熟睡| 久久综合狠狠综合久久综合88| 亚洲国产精品嫩草影院| 91麻豆自制传媒国产之光| 欧美国产一区在线| 极品少妇一区二区三区精品视频| 欧美精品在线视频| 一区二区三区欧美日| 成人av一区二区三区| 久久久91精品国产一区二区三区| 青青草原综合久久大伊人精品 | 成人高清免费观看| 日韩一区二区不卡| 午夜视频一区二区三区| 91免费国产在线观看| 亚洲国产高清不卡| 国产精品 欧美精品| 久久久综合精品| 久热成人在线视频| 欧美一区二区三区免费视频| 午夜精品久久一牛影视| 欧美午夜一区二区三区| 亚洲精品第1页| 色综合激情五月| ...av二区三区久久精品| 岛国精品一区二区| 亚洲国产成人在线| 成人av在线电影| 亚洲欧美在线视频| 91亚洲精品久久久蜜桃| 亚洲欧美日韩一区二区 | 亚洲美女电影在线| www.日韩av| 亚洲人成7777| 99久久婷婷国产综合精品| 中文字幕免费不卡在线| 东方欧美亚洲色图在线| 国产精品毛片高清在线完整版| 成人免费av网站| 亚洲精品中文在线观看| 在线观看视频91| 一区二区三区不卡视频| 欧美日韩国产成人在线免费| 亚洲3atv精品一区二区三区| 在线电影一区二区三区| 免费成人美女在线观看| xf在线a精品一区二区视频网站| 国产精品影视在线| 国产精品久久毛片av大全日韩| 99久久伊人网影院| 亚洲一区二区在线播放相泽| 欧美日韩高清一区| 久久国产日韩欧美精品| 久久女同互慰一区二区三区| 高清av一区二区| 亚洲男帅同性gay1069| 欧美日韩一区二区电影| 毛片av一区二区三区| 久久精品亚洲国产奇米99| 成人国产精品免费网站| 亚洲成人免费影院| 精品国产免费人成在线观看| 成人免费视频播放| 亚洲五月六月丁香激情| 精品日韩欧美在线| 成人毛片在线观看| 一区二区三区欧美| 日韩欧美国产综合在线一区二区三区| 国产精品一二三四五| 亚洲三级在线免费| 欧美一区二区观看视频| 懂色av中文字幕一区二区三区| 亚洲精品久久久蜜桃| 亚洲午夜电影网| 亚洲精品一区二区三区99| av在线不卡观看免费观看| 亚洲一区二区精品视频| 日韩亚洲欧美综合| 国产成人8x视频一区二区| 亚洲成人一区在线| 久久久久久久久久久久久久久99 | 一区二区三区欧美日韩| 精品久久久久久久久久久久久久久久久 | 91视频国产观看| 日韩av一级电影| 亚洲国产高清在线| 91精选在线观看| aaa国产一区| 极品尤物av久久免费看| 亚洲一区免费视频| www国产精品av| 欧美精品在线一区二区| eeuss鲁片一区二区三区在线看| 天堂蜜桃91精品| 亚洲视频一二区| 久久久精品影视| 日韩午夜激情电影| 91麻豆6部合集magnet| 国产一区二区三区在线看麻豆| 一区二区三区不卡视频在线观看 | 成人av网站在线| 麻豆91免费观看| 亚洲妇女屁股眼交7| 国产精品网站导航| 日韩色视频在线观看| 欧美做爰猛烈大尺度电影无法无天| 国产精品88av| 毛片不卡一区二区| 午夜精品久久久久久久99樱桃| 亚洲天堂成人网| 国产精品私人影院| 久久免费午夜影院| 日韩精品一区二区三区四区| 欧美日韩一区三区四区| 成人精品免费视频| 国产精品亚洲一区二区三区妖精| 日韩成人一区二区三区在线观看| 一区二区三区四区在线免费观看 | 一本色道**综合亚洲精品蜜桃冫| 精品亚洲porn| 蜜桃av一区二区三区电影| 亚洲电影第三页| 一区二区三区久久久| 亚洲三级久久久| 亚洲欧洲日韩在线| 1区2区3区国产精品| 国产精品丝袜黑色高跟| 久久久久久久国产精品影院| 欧美一二三区精品| 欧美一区二区福利视频| 91精品国产麻豆国产自产在线 | 狠狠色狠狠色合久久伊人| 日韩精品一二三| 日韩av一区二区三区四区| 五月天亚洲婷婷| 日日摸夜夜添夜夜添精品视频| 亚洲h在线观看| 午夜av区久久| 欧美影院午夜播放| 精品视频在线视频| 欧美日韩一区二区三区四区| 欧美日韩免费高清一区色橹橹 | 日本强好片久久久久久aaa| 图片区小说区国产精品视频| 午夜日韩在线电影| 免费av网站大全久久| 青青青爽久久午夜综合久久午夜| 日韩av在线免费观看不卡| 捆绑调教美女网站视频一区| 国产尤物一区二区在线| 国产成人av影院| 99精品在线观看视频| 在线免费观看成人短视频| 欧美色精品天天在线观看视频| 欧美日韩aaaaa| 欧美电视剧免费观看| 久久午夜羞羞影院免费观看| 国产日产欧产精品推荐色| 中日韩免费视频中文字幕| 亚洲欧美日韩国产综合| 亚洲成人手机在线| 九九精品一区二区| 成人的网站免费观看|