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

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

?? os_sem.c

?? 嵌入式操作系統源碼
?? 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)
{
#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                      */
        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)
{
#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一区二区三区免费野_久草精品视频
日韩一级免费观看| 337p粉嫩大胆噜噜噜噜噜91av| 日韩一区二区三区免费看| 中文成人av在线| 日韩成人一级大片| 91黄视频在线| 综合久久久久久| 国产成人av电影在线观看| 777午夜精品免费视频| 亚洲猫色日本管| 成人一区二区在线观看| 精品少妇一区二区三区在线播放| 又紧又大又爽精品一区二区| 成人小视频免费在线观看| 日韩一区二区三区电影| 首页亚洲欧美制服丝腿| 欧洲一区二区三区在线| 亚洲男人电影天堂| 99re6这里只有精品视频在线观看| 久久久久久97三级| 国产一区二区0| 久久免费电影网| 激情久久久久久久久久久久久久久久| 欧美日韩成人在线| 爽好多水快深点欧美视频| 欧美日韩精品一区二区三区蜜桃 | 欧美猛男超大videosgay| 亚洲免费av观看| 成人免费视频免费观看| 久久夜色精品国产欧美乱极品| 蜜臀av国产精品久久久久| 日韩午夜激情免费电影| 久久丁香综合五月国产三级网站| 日韩一区二区三区四区| 久久99精品久久久久久久久久久久| 日韩欧美一卡二卡| 国产一区二区三区久久久| 久久先锋影音av鲁色资源| 国产成人小视频| 国产精品久久久久久久久果冻传媒| 丁香婷婷综合五月| 亚洲免费在线观看视频| 欧美在线观看禁18| 视频一区视频二区中文| 日韩欧美国产综合一区| 国产suv精品一区二区6| 亚洲欧美欧美一区二区三区| 欧美色图12p| 日本亚洲电影天堂| 久久久久久久综合狠狠综合| 99re在线视频这里只有精品| 亚洲国产成人av网| 久久久亚洲精品一区二区三区 | 国产日韩一级二级三级| 北条麻妃一区二区三区| 亚洲成人www| 久久精品夜色噜噜亚洲a∨| voyeur盗摄精品| 婷婷综合在线观看| 国产欧美日韩三级| 欧美日韩精品免费| 国内精品伊人久久久久av一坑 | 99久久伊人久久99| 婷婷六月综合网| 日本一区二区三区dvd视频在线| 99精品久久免费看蜜臀剧情介绍| 日日夜夜免费精品| 国产精品久久久久桃色tv| 在线播放91灌醉迷j高跟美女| 久久精品国内一区二区三区| 亚洲欧美日韩电影| 欧美一级免费大片| www.亚洲色图| 久久99国产精品久久| 一区二区三区在线观看国产| 久久综合九色综合久久久精品综合| 99re66热这里只有精品3直播| 久久电影网电视剧免费观看| 亚洲综合免费观看高清完整版在线| 精品免费国产二区三区| 欧美日韩视频一区二区| 99久久99久久精品国产片果冻| 人妖欧美一区二区| 亚洲一区二区三区不卡国产欧美 | 欧美国产日本韩| 中文字幕欧美日本乱码一线二线| 国产成人在线视频免费播放| 国产精品久久99| 欧美日韩国产在线观看| 久久国产日韩欧美精品| 美国三级日本三级久久99| 91福利在线观看| 精品国产乱码久久久久久影片| 欧美日韩免费观看一区三区| 婷婷久久综合九色综合绿巨人| caoporn国产精品| 国产精品美日韩| 国产一区二区三区在线观看免费视频| 亚洲欧洲韩国日本视频| 在线观看日韩电影| 国产精品77777竹菊影视小说| 亚洲激情综合网| 久久这里都是精品| 欧美电影影音先锋| 欧美性xxxxxx少妇| 欧美中文字幕一二三区视频| 在线免费观看日本一区| 成人理论电影网| 成人污污视频在线观看| 久久99久久精品欧美| 偷拍一区二区三区四区| 国产精品色在线| 欧美日韩国产美女| 在线不卡一区二区| 欧美日韩在线电影| 欧美电视剧免费全集观看 | 日韩黄色小视频| 日韩vs国产vs欧美| 激情六月婷婷久久| 日韩在线a电影| 全国精品久久少妇| 在线观看日韩国产| 色香蕉久久蜜桃| 欧美精品乱人伦久久久久久| 久久久久国产一区二区三区四区| 日韩欧美中文字幕一区| 亚洲视频一区在线| 亚洲精品国产精华液| 国产在线一区二区| 日韩精品中文字幕一区二区三区 | 日韩精品一区二区三区四区| 国产午夜亚洲精品羞羞网站| 亚洲视频在线一区二区| 亚洲高清免费观看| 成人久久视频在线观看| 337p亚洲精品色噜噜狠狠| 久久久蜜桃精品| 日韩中文字幕1| 欧美日韩精品福利| 亚洲欧洲精品一区二区三区| 看国产成人h片视频| 欧美午夜精品免费| 欧美网站一区二区| 一区二区三区鲁丝不卡| 久久精品国产99国产| 本田岬高潮一区二区三区| 中文文精品字幕一区二区| 秋霞国产午夜精品免费视频| 欧美另类z0zxhd电影| 亚洲精品国产成人久久av盗摄| 国产一区二区三区在线看麻豆| 国产精品亲子乱子伦xxxx裸| 成人综合在线网站| 秋霞成人午夜伦在线观看| 亚洲丝袜美腿综合| 日韩一区二区三区四区| 99国产欧美另类久久久精品 | 99精品黄色片免费大全| 亚洲视频免费在线| 欧美性色黄大片| 国产一区二区精品久久91| 国产精品久久99| 欧美日韩一区在线观看| 国产一区二区三区在线观看精品| 亚洲欧美激情视频在线观看一区二区三区 | 国产原创一区二区| 久久久91精品国产一区二区三区| 国内精品久久久久影院色 | 国产在线精品一区二区不卡了 | 99久久久精品| 五月天久久比比资源色| xnxx国产精品| 欧美写真视频网站| 免费精品99久久国产综合精品| 国产校园另类小说区| 在线观看日韩av先锋影音电影院| 日韩精品视频网站| 国产精品色哟哟| 欧美精品一区二区三区一线天视频| 国产成人精品三级| 老司机免费视频一区二区| 亚洲男同性恋视频| 久久精子c满五个校花| 欧美日韩免费电影| 99精品欧美一区| 国产不卡免费视频| 国产精品一区二区三区乱码 | 国内精品国产成人| 蜜臀精品一区二区三区在线观看 | 午夜精品久久久久久久久| 日韩一区二区三区观看| 成人手机电影网| 国产精品一级二级三级| 亚洲国产毛片aaaaa无费看| 亚洲一二三四久久| 欧美国产一区二区| 精品盗摄一区二区三区| 日本电影亚洲天堂一区| 成人免费视频一区二区| 美女一区二区视频|