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

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

?? os_sem.c

?? uc0s zai 51 上的移植
?? 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)LG_REENTRANT
{
#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)LG_REENTRANT
{
#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)LG_REENTRANT
{
#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一区二区三区免费野_久草精品视频
国产高清久久久| 欧美一区二区三区的| 欧美精品一区二| 免费欧美日韩国产三级电影| 欧美丰满少妇xxxbbb| 午夜精品福利一区二区蜜股av| 91精品福利在线| 婷婷成人激情在线网| 亚洲一区在线观看视频| 欧美日韩国产区一| 国产精品1区二区.| 伊人婷婷欧美激情| 精品久久久久久综合日本欧美 | 亚洲综合成人在线| 亚洲一区二区三区四区在线| 偷拍日韩校园综合在线| 免费久久99精品国产| 国产在线播精品第三| 亚洲综合久久久久| 日韩精品成人一区二区在线| 亚洲欧洲av在线| 欧美精品久久99| 精品粉嫩超白一线天av| 欧美在线小视频| 高清av一区二区| 性做久久久久久免费观看 | 国产精品久久久久久户外露出| 欧美三级资源在线| 懂色av一区二区在线播放| 91丨国产丨九色丨pron| 久久99精品久久久久婷婷| 亚洲综合色在线| 久久av中文字幕片| 日韩成人一级片| 五月婷婷另类国产| 国产精品一级黄| 欧美性videosxxxxx| 91视频91自| 日韩欧美一区二区视频| 欧美一区二区三区免费视频| 国产欧美在线观看一区| 久久亚洲一级片| 亚洲宅男天堂在线观看无病毒| 美女一区二区久久| 久久国产三级精品| 色婷婷综合久久| 91丨porny丨首页| 欧美不卡一二三| 一区二区三区**美女毛片| 一区二区三区在线看| 久久99精品久久久久久动态图| 在线看一区二区| 国产欧美日韩精品a在线观看| 三级久久三级久久久| 色综合欧美在线视频区| 国产视频视频一区| 国产精品美女一区二区在线观看| 久久精品视频网| 天涯成人国产亚洲精品一区av| 不卡电影一区二区三区| 91影院在线免费观看| 久久精品人人爽人人爽| 蜜桃视频一区二区| 欧美男人的天堂一二区| 亚洲激情网站免费观看| 成人av在线资源网| 欧美高清在线一区二区| 亚洲视频一二三区| 性久久久久久久| 一本色道a无线码一区v| 国产精品久久久久aaaa| 国产成a人无v码亚洲福利| 亚洲精品一区二区精华| 精东粉嫩av免费一区二区三区| 欧美乱妇15p| 亚洲电影在线播放| 国产一区二区福利视频| 欧美tk丨vk视频| 国产在线播放一区二区三区| 久久九九久精品国产免费直播| 久草精品在线观看| 久久久噜噜噜久噜久久综合| 亚洲女子a中天字幕| 蜜臀av性久久久久蜜臀aⅴ| 欧美猛男超大videosgay| 亚洲香肠在线观看| 777午夜精品免费视频| 中文字幕欧美日韩一区| 成人av网站大全| 亚洲精品国久久99热| 日本伦理一区二区| 日本一区中文字幕| 精品国产sm最大网站| 国产成人免费视| 亚洲美女免费在线| 欧美日韩国产成人在线免费| 日本怡春院一区二区| 2023国产精华国产精品| 成人精品一区二区三区四区| 欧美一区二区三区四区久久| 国产专区综合网| 日韩欧美亚洲国产精品字幕久久久| 麻豆一区二区在线| 国产精品视频一二| 色94色欧美sute亚洲线路一久 | 久久久不卡网国产精品一区| 99r精品视频| 国产精品麻豆久久久| 91在线云播放| 久久精品国产精品亚洲红杏| 国产精品妹子av| 在线成人高清不卡| 成人动漫中文字幕| 日本成人在线一区| 国产精品久久久99| 欧美一级精品在线| 日韩av中文字幕一区二区三区| 国产欧美一区二区精品久导航| 欧美在线免费播放| 成人丝袜视频网| 日韩av中文在线观看| 亚洲日本一区二区| 国产欧美一区二区精品性色超碰 | 国产毛片精品一区| 亚洲综合在线五月| 日本一区二区三区在线观看| 欧美肥妇free| 日本韩国精品一区二区在线观看| 精品一区二区在线看| 亚洲午夜精品一区二区三区他趣| 国产亚洲人成网站| 日韩精品一区二区三区中文不卡| 91国产免费观看| 99re免费视频精品全部| 国内偷窥港台综合视频在线播放| 婷婷六月综合亚洲| 亚洲国产综合视频在线观看| 亚洲视频一区二区免费在线观看| 久久精品一区二区三区四区 | 国产一区二区福利视频| 麻豆中文一区二区| 免费在线观看日韩欧美| 亚洲444eee在线观看| 亚洲人成精品久久久久久| 国产精品日日摸夜夜摸av| 久久色.com| 国产亚洲综合性久久久影院| 精品国产乱码久久久久久老虎| 51精品视频一区二区三区| 精品视频123区在线观看| 一本大道久久a久久精品综合| a亚洲天堂av| 日韩av不卡在线观看| 亚洲国产精品久久久久秋霞影院| 亚洲精品视频一区| 一区二区三区中文字幕在线观看| 亚洲欧美日韩中文字幕一区二区三区 | 精品一区二区免费视频| 久久精品国内一区二区三区| 美美哒免费高清在线观看视频一区二区| 亚洲一区二区三区视频在线播放| 亚洲一区二区三区四区五区中文| 亚洲成人福利片| 奇米色777欧美一区二区| 免费成人美女在线观看.| 韩国av一区二区三区在线观看 | 1000精品久久久久久久久| 亚洲欧美色综合| 亚洲成人av免费| 蜜臀精品一区二区三区在线观看 | 日韩影院免费视频| 久久国产精品第一页| 国产乱子轮精品视频| 成人综合在线观看| 色素色在线综合| 3atv在线一区二区三区| 亚洲精品在线免费播放| 国产精品久久夜| 亚洲成人免费看| 国产精品夜夜嗨| 色av一区二区| 精品国精品国产| 亚洲精品欧美激情| 久久国产精品无码网站| 成人亚洲精品久久久久软件| 欧美色手机在线观看| 久久久精品免费观看| 亚洲另类在线一区| 久久电影网站中文字幕| 91免费视频网| 欧美一区二区视频观看视频 | 欧美无砖砖区免费| 久久九九久精品国产免费直播| 尤物av一区二区| 国产精品中文字幕日韩精品| 日本韩国欧美在线| 国产三级一区二区三区| 亚洲第一狼人社区| av电影在线观看不卡| 日韩你懂的在线播放|