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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? LPC2104/5/6嵌入式系統(tǒng)程序?qū)嵗?帶有PROTUES7.1仿真文件,適合做入門指導(dǎo)
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/*
*********************************************************************************************************
*                                                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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品一区二区三区视频 | 日韩一区二区三区免费看 | 视频一区视频二区中文字幕| 欧美xxxxxxxx| 91国偷自产一区二区开放时间| 日本成人在线看| 日韩理论电影院| 精品国产制服丝袜高跟| 色激情天天射综合网| 国产裸体歌舞团一区二区| 午夜久久福利影院| 国产精品国产三级国产有无不卡 | 777欧美精品| 色综合久久久久综合99| 国产尤物一区二区在线| 亚洲一二三四在线观看| 国产精品欧美综合在线| 欧美tickle裸体挠脚心vk| 欧洲亚洲精品在线| 成人高清视频在线观看| 久久er99热精品一区二区| 亚洲电影一级片| 国产精品成人在线观看| 久久色.com| 91精品国产麻豆| 欧美三级三级三级| 91性感美女视频| 成人中文字幕合集| 国产精选一区二区三区| 丝袜诱惑亚洲看片| 亚洲最快最全在线视频| 亚洲视频每日更新| 国产精品卡一卡二| 欧美韩日一区二区三区四区| 欧美α欧美αv大片| 91精品国产入口在线| 欧美伊人久久久久久久久影院| av电影在线观看一区| 高清shemale亚洲人妖| 国产成人啪免费观看软件| 精品一区二区免费在线观看| 久久超碰97中文字幕| 美洲天堂一区二卡三卡四卡视频| 天天亚洲美女在线视频| 五月天中文字幕一区二区| 亚洲国产另类av| 亚洲成年人影院| 亚洲超碰精品一区二区| 日韩精品亚洲一区二区三区免费| 亚洲国产一区二区三区| 日韩精品欧美精品| 麻豆国产精品777777在线| 免费久久精品视频| 韩国精品一区二区| 成人免费毛片高清视频| 99久久精品久久久久久清纯| 99久久精品久久久久久清纯| 色www精品视频在线观看| 欧美午夜寂寞影院| 91麻豆精品国产自产在线 | 不卡av在线网| aaa国产一区| 日本韩国一区二区三区| 在线91免费看| 欧美成人一区二区三区在线观看| 26uuu亚洲婷婷狠狠天堂| 国产女主播在线一区二区| 国产精品久久久久久亚洲伦| 亚洲欧洲综合另类| 亚洲444eee在线观看| 极品瑜伽女神91| 床上的激情91.| 一本色道综合亚洲| 欧美一区二区三区视频| 久久免费精品国产久精品久久久久 | av在线不卡电影| 欧美在线观看一区二区| 日韩免费一区二区| 亚洲国产电影在线观看| 亚洲制服丝袜在线| 精品系列免费在线观看| hitomi一区二区三区精品| 欧美在线观看一区| 久久精品视频免费| 亚洲自拍偷拍欧美| 激情深爱一区二区| 色一区在线观看| 日韩亚洲电影在线| 亚洲欧美影音先锋| 日韩av在线播放中文字幕| 国产sm精品调教视频网站| 欧美图片一区二区三区| 亚洲精品一区二区三区99| 亚洲欧美日韩国产手机在线 | av一本久道久久综合久久鬼色| 欧美日韩精品一区二区| 国产日韩精品一区| 香港成人在线视频| 粉嫩欧美一区二区三区高清影视| 欧美三级电影在线看| 国产日韩欧美精品电影三级在线| 一区二区三区在线免费观看| 国内偷窥港台综合视频在线播放| 91小视频免费观看| 久久综合给合久久狠狠狠97色69| 亚洲一区二区三区四区的| 国产精品资源站在线| 欧美乱妇15p| 中文字幕一区免费在线观看| 蜜臀久久99精品久久久久久9| 成人一区在线看| 日韩午夜在线影院| 亚洲一区二区三区四区五区中文| 国产经典欧美精品| 日韩三级免费观看| 亚洲高清免费一级二级三级| av成人免费在线| 久久蜜臀精品av| 欧美aaaaa成人免费观看视频| 91在线国产观看| 久久精品夜夜夜夜久久| 青青草伊人久久| 欧美二区在线观看| 亚洲主播在线播放| 在线观看亚洲专区| 亚洲日本电影在线| 99热这里都是精品| 欧美国产日韩a欧美在线观看| 免费高清在线视频一区·| 欧美系列日韩一区| 亚洲综合一二区| 色综合久久中文字幕| 国产精品传媒在线| 波多野结衣中文字幕一区 | 欧美午夜精品久久久久久超碰 | 国产精品资源站在线| 精品久久久网站| 日韩av午夜在线观看| 69精品人人人人| 亚洲成av人**亚洲成av**| 欧美日韩中字一区| 亚洲香肠在线观看| 欧美视频一区二区在线观看| 亚洲精品国产无天堂网2021| 一本大道久久a久久精二百| 中文字幕一区不卡| 99在线热播精品免费| 亚洲日本护士毛茸茸| 欧美系列亚洲系列| 日韩专区欧美专区| 日韩午夜电影av| 久草这里只有精品视频| 久久精品水蜜桃av综合天堂| 国产69精品久久久久777| 欧美国产国产综合| 色综合久久六月婷婷中文字幕| 夜夜嗨av一区二区三区网页| 欧美日韩小视频| 日本中文一区二区三区| 欧美va在线播放| 国产精品亚洲第一| 国产精品国产三级国产有无不卡 | 日韩免费成人网| 国产成人亚洲精品青草天美| 国产精品视频看| 99re8在线精品视频免费播放| 一区二区三区欧美视频| 欧美剧情电影在线观看完整版免费励志电影| 亚洲电影你懂得| 日韩视频一区二区在线观看| 国产一区二区三区四区五区入口| 国产精品免费人成网站| 在线观看亚洲成人| 蜜桃视频在线一区| 国产精品国产三级国产aⅴ入口| 色先锋久久av资源部| 免费欧美在线视频| 中文字幕中文字幕一区二区| 欧美日韩激情一区二区三区| 国内成人精品2018免费看| 亚洲欧洲一区二区在线播放| 欧美狂野另类xxxxoooo| 国产成人精品aa毛片| 亚洲综合在线电影| 精品久久久久久久人人人人传媒 | 国产成人啪免费观看软件| 一区二区三区丝袜| 精品免费99久久| av高清久久久| 久久精品国产网站| 亚洲免费在线视频| 精品少妇一区二区| 91成人在线观看喷潮| 极品瑜伽女神91| 亚洲在线免费播放| 亚洲国产成人一区二区三区| 欧美福利电影网| 成人av在线资源网站| 青椒成人免费视频| 亚洲欧美激情小说另类|