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

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

?? os_sem.c

?? uCOS開發與源碼
?? 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一区二区三区免费野_久草精品视频
另类小说图片综合网| 91在线国产观看| 波多野结衣91| 欧美日韩日本视频| 国产精品你懂的在线欣赏| 午夜影院久久久| aaa欧美大片| 久久丝袜美腿综合| 婷婷久久综合九色国产成人| 成人av影院在线| 精品少妇一区二区三区在线视频| 亚洲卡通欧美制服中文| 丰满放荡岳乱妇91ww| 欧美成人欧美edvon| 日韩av午夜在线观看| 色噜噜狠狠一区二区三区果冻| 国产亚洲成aⅴ人片在线观看| 日韩和欧美一区二区| 色av成人天堂桃色av| 国产精品欧美极品| 粉嫩av一区二区三区粉嫩| 久久久精品免费观看| 精品亚洲国产成人av制服丝袜| 欧美日韩国产高清一区| 亚洲综合激情另类小说区| 99久久er热在这里只有精品15| 国产欧美一区二区三区鸳鸯浴| 黑人巨大精品欧美黑白配亚洲| 欧美一区二区三区日韩视频| 日韩在线一区二区| 欧美天天综合网| 一区二区三区四区视频精品免费| 94-欧美-setu| 亚洲激情网站免费观看| 欧美色精品在线视频| 天天操天天干天天综合网| 欧美色图激情小说| 热久久久久久久| 欧美成人猛片aaaaaaa| 国产精品伊人色| 综合久久综合久久| 欧美三级韩国三级日本一级| 亚洲一区二区三区免费视频| 91精品在线一区二区| 麻豆91在线播放| 日本一区免费视频| 99热在这里有精品免费| 亚洲精品国产一区二区精华液| 欧美中文字幕久久| 蜜桃免费网站一区二区三区| 久久久亚洲精品石原莉奈| 国产老妇另类xxxxx| 亚洲欧洲另类国产综合| 色综合久久久久综合99| 亚洲一区二区偷拍精品| 欧美一区二区高清| 国产成人高清在线| 亚洲小少妇裸体bbw| 精品欧美一区二区三区精品久久| 成人午夜电影小说| 亚洲成av人综合在线观看| 精品国精品自拍自在线| 99久久精品免费观看| 亚洲一区在线观看免费| 欧美精品一区二区高清在线观看| 成人动漫一区二区三区| 婷婷久久综合九色综合绿巨人 | 国产亚洲女人久久久久毛片| 不卡免费追剧大全电视剧网站| 亚洲一区二区不卡免费| 久久综合九色综合欧美亚洲| 色嗨嗨av一区二区三区| 激情五月婷婷综合| 一区二区三区在线免费| 精品999在线播放| 欧美亚洲国产一卡| 国产精品资源站在线| 亚洲成a人v欧美综合天堂下载 | 在线不卡一区二区| 成人在线综合网| 日本欧美在线观看| 一区二区三区在线视频观看 | 成人av手机在线观看| 五月天久久比比资源色| 中文字幕一区二区三区在线播放| 3d动漫精品啪啪一区二区竹菊 | 成人视屏免费看| 久久丁香综合五月国产三级网站| 亚洲视频每日更新| 国产日本一区二区| 2023国产精华国产精品| 正在播放一区二区| 欧美图片一区二区三区| 91女厕偷拍女厕偷拍高清| 国产毛片精品一区| 久久国产欧美日韩精品| 舔着乳尖日韩一区| 亚洲狼人国产精品| 亚洲人成精品久久久久久| 国产天堂亚洲国产碰碰| 欧美不卡一区二区三区| 欧美一三区三区四区免费在线看 | 精品国产凹凸成av人导航| 欧美乱妇20p| 欧美精品九九99久久| 在线视频综合导航| 色美美综合视频| 99riav一区二区三区| yourporn久久国产精品| 国产成人久久精品77777最新版本| 捆绑紧缚一区二区三区视频| 免费在线观看视频一区| 青青国产91久久久久久| 蜜桃精品在线观看| 久久99国产精品久久| 狠狠色丁香久久婷婷综| 国产成a人亚洲精品| 成人午夜视频在线观看| 成人av在线看| 色激情天天射综合网| 欧美日本精品一区二区三区| 欧美日本在线播放| 日韩欧美激情一区| 国产女主播一区| 亚洲欧洲中文日韩久久av乱码| 亚洲乱码中文字幕| 午夜日韩在线观看| 精品一区二区三区免费观看| 国产麻豆精品久久一二三| jizz一区二区| 欧美日韩高清在线播放| 91精品国产色综合久久不卡蜜臀 | 日韩欧美成人午夜| 国产亚洲综合在线| 亚洲欧洲美洲综合色网| 亚洲综合在线观看视频| 奇米色一区二区| 国产成人综合自拍| 91麻豆文化传媒在线观看| 欧美绝品在线观看成人午夜影视| 欧美不卡激情三级在线观看| 亚洲国产精品成人综合色在线婷婷| 亚洲色图制服丝袜| 丝袜美腿亚洲色图| 高清成人在线观看| 欧美性感一区二区三区| 精品国产乱码91久久久久久网站| 国产精品麻豆网站| 免费成人美女在线观看.| 国产激情一区二区三区| 色久综合一二码| 久久欧美一区二区| 亚洲黄色av一区| 国产乱码精品1区2区3区| 欧美在线观看一区| 国产精品视频在线看| 同产精品九九九| 一本久道中文字幕精品亚洲嫩 | 国产一区二区在线看| 一本一道久久a久久精品 | 欧美www视频| 亚洲精品国产高清久久伦理二区| 奇米综合一区二区三区精品视频| 国产 欧美在线| 精品国产免费人成电影在线观看四季| 最新国产成人在线观看| 精品一区二区三区av| 91精品办公室少妇高潮对白| 国产偷国产偷亚洲高清人白洁| 婷婷国产在线综合| 色综合咪咪久久| 亚洲国产成人午夜在线一区| 美女视频第一区二区三区免费观看网站| 成人av资源网站| 国产日韩欧美一区二区三区综合| 亚洲成av人片一区二区| 色综合天天性综合| 国产区在线观看成人精品| 日本欧美一区二区| 欧美日本在线播放| 亚洲午夜在线观看视频在线| 91欧美激情一区二区三区成人| 日本一区二区三区久久久久久久久不| 蜜臀av一区二区| 欧美一区二区三区免费在线看| 一区二区三区国产| 91久久奴性调教| 亚洲乱码国产乱码精品精可以看 | 免费看日韩精品| 欧美一区二区三区视频免费播放 | 9191成人精品久久| 亚洲第一福利一区| 欧美亚洲一区二区三区四区| 中文字幕一区在线观看视频| 成人毛片老司机大片| 国产精品色呦呦| 波多野洁衣一区| 一区二区三区在线观看欧美 | 成人h动漫精品| 国产精品护士白丝一区av|