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

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

?? os_sem.c

?? LPC2104/5/6的嵌入式程序及其仿真文件,適合入門指導
?? 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一区二区三区免费野_久草精品视频
久久久久久久av麻豆果冻| 中文字幕在线不卡一区| 日韩视频123| 一级日本不卡的影视| 国产一区二区三区四区五区美女| 狠狠色丁香婷婷综合| 日韩一区二区免费在线观看| 91精品一区二区三区在线观看| 亚洲国产一区二区在线播放| 成人免费视频caoporn| 国产精品电影院| 欧美一区在线视频| 一区二区三区四区高清精品免费观看 | 99久久久久免费精品国产| 亚洲大片一区二区三区| 国产精品久久夜| 久久综合成人精品亚洲另类欧美| 欧美久久久久久久久| 99综合影院在线| 国产aⅴ综合色| 美女一区二区在线观看| 亚洲国产视频在线| 亚洲人成网站影音先锋播放| 国产亚洲va综合人人澡精品| 日韩欧美一级二级三级久久久| 91极品视觉盛宴| 91影院在线观看| 国产成人自拍网| 精品在线一区二区| 美女免费视频一区| 五月天亚洲精品| 亚洲成人av电影| 亚洲第一综合色| 亚洲成av人在线观看| 亚洲一区免费在线观看| 亚洲综合在线第一页| 日韩毛片视频在线看| 亚洲欧美综合色| 国产精品日韩精品欧美在线| 久久久久久97三级| 久久精品日产第一区二区三区高清版| 欧美成人高清电影在线| 欧美一级日韩免费不卡| 日韩视频在线一区二区| 日韩免费看的电影| 精品成人一区二区三区| 精品女同一区二区| 精品精品欲导航| 久久综合色之久久综合| 亚洲国产美女搞黄色| 亚洲最新视频在线播放| 亚洲一区影音先锋| 午夜av一区二区三区| 日本不卡一区二区三区| 婷婷综合在线观看| 另类专区欧美蜜桃臀第一页| 激情综合色综合久久| 国产一区激情在线| 粉嫩av一区二区三区粉嫩| www.亚洲人| 欧美亚洲综合另类| 欧美一区二区三区在线电影| 欧美电影免费观看高清完整版在线观看| 欧美成人bangbros| 久久久欧美精品sm网站| 欧美激情资源网| 一区二区三区不卡在线观看| 三级久久三级久久| 国产伦精品一区二区三区免费| 成人综合婷婷国产精品久久 | 另类小说色综合网站| 韩国一区二区视频| 成人18视频在线播放| 色综合久久久久综合体桃花网| 精品视频资源站| 精品国产乱码久久久久久免费| 中文字幕免费不卡| 亚洲午夜精品网| 精品一区二区三区蜜桃| 99国产精品久| 91精品综合久久久久久| 国产亚洲视频系列| 亚洲综合色自拍一区| 久久国产精品色婷婷| 99精品在线免费| 91精品国产全国免费观看 | 欧美videos中文字幕| √…a在线天堂一区| 免费在线看成人av| 93久久精品日日躁夜夜躁欧美| 亚洲电影在线播放| 韩日精品视频一区| 欧美三级日韩三级国产三级| 国产女主播在线一区二区| 亚洲一区二区三区在线播放| 经典一区二区三区| 欧美三区在线观看| 久久精品欧美一区二区三区不卡| 亚洲图片欧美色图| 国产成人免费视频一区| 欧美精品日日鲁夜夜添| 国产精品高潮呻吟| 蜜臀av性久久久久蜜臀aⅴ流畅| av不卡免费电影| 日韩精品一区二区三区在线| 亚洲伦理在线精品| 国产乱色国产精品免费视频| 欧美精选在线播放| 亚洲欧美日韩中文字幕一区二区三区| 久久精品二区亚洲w码| 欧美制服丝袜第一页| 亚洲国产成人私人影院tom| 免费在线观看成人| 欧美日韩一区二区欧美激情| 亚洲日本乱码在线观看| 韩国v欧美v亚洲v日本v| 欧美日韩精品免费观看视频| 亚洲女同女同女同女同女同69| 国产美女娇喘av呻吟久久| 亚洲成人资源网| 在线免费亚洲电影| 中文字幕亚洲电影| 国产高清亚洲一区| 欧美精品一区二区在线观看| 青青草国产精品97视觉盛宴 | 成人一区二区三区视频在线观看| 日韩免费观看高清完整版在线观看| 亚洲第一激情av| 欧美性xxxxxxxx| 亚洲免费观看高清完整版在线观看 | 91色porny蝌蚪| 国产精品久久久久四虎| 国产成人午夜精品5599| 久久久久久麻豆| 精品一区二区久久| 精品国产欧美一区二区| 美女视频第一区二区三区免费观看网站 | 亚洲综合在线视频| 91色视频在线| 一区二区三区不卡视频| 欧美亚男人的天堂| 亚洲香肠在线观看| 欧美日韩一区国产| 水野朝阳av一区二区三区| 91精品国产麻豆国产自产在线| 日日夜夜精品视频免费| 日韩欧美国产电影| 韩国视频一区二区| 中文字幕欧美国产| 91在线观看视频| 一区二区理论电影在线观看| 欧美日韩免费一区二区三区| 亚洲6080在线| 欧美大片在线观看一区二区| 韩国v欧美v日本v亚洲v| 亚洲国产精品99久久久久久久久| www.久久精品| 亚洲一二三四久久| 在线不卡免费av| 久久97超碰国产精品超碰| 久久久国产精品不卡| thepron国产精品| 曰韩精品一区二区| 欧美一区二区精品在线| 久久国产精品99精品国产| 日本一区二区三级电影在线观看| aaa亚洲精品| 亚洲va在线va天堂| 日韩不卡免费视频| 久久日韩精品一区二区五区| 不卡的电影网站| 亚洲第一电影网| 久久中文娱乐网| 色综合天天天天做夜夜夜夜做| 亚洲图片自拍偷拍| 久久婷婷成人综合色| 色av成人天堂桃色av| 蜜桃久久精品一区二区| 国产精品三级视频| 3d动漫精品啪啪一区二区竹菊 | 亚洲丝袜精品丝袜在线| 在线不卡一区二区| 成人一区二区视频| 五月天视频一区| 欧美国产视频在线| 欧美美女一区二区| 国产一区二区女| 一区二区三区产品免费精品久久75| 欧美一区二区精品| 91丝袜高跟美女视频| 久色婷婷小香蕉久久| 亚洲色图欧洲色图婷婷| 日韩女同互慰一区二区| 色婷婷综合久久久久中文一区二区| 日本亚洲三级在线| 亚洲欧美偷拍另类a∨色屁股| 精品国精品自拍自在线| 色噜噜偷拍精品综合在线| 国产精品12区| 日本网站在线观看一区二区三区|