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

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

?? os_sem.c

?? 51單片機(jī)上移植UCOSII,通過調(diào)試
?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成av人片在线观看无码| 国产欧美一区二区精品久导航| 精品99一区二区三区| 亚洲免费视频成人| 欧美在线色视频| 中文字幕一区二区三中文字幕 | 国产精品久久福利| 一本一道久久a久久精品| 三级久久三级久久| 欧美国产日韩亚洲一区| 久久亚洲捆绑美女| aaa欧美色吧激情视频| 在线免费视频一区二区| 国产情人综合久久777777| 久久久另类综合| 国产99久久久国产精品免费看| 欧美videofree性高清杂交| 精品亚洲成a人| 久久新电视剧免费观看| 狠狠色伊人亚洲综合成人| 国产亚洲一二三区| 69堂成人精品免费视频| 在线免费观看日本一区| 5月丁香婷婷综合| 精品日韩在线一区| 日韩精品一区二区三区视频在线观看 | 国产精品亲子伦对白| 欧美高清在线一区| 日一区二区三区| 国产三级欧美三级| 亚洲一区二区三区激情| 欧美老人xxxx18| 黄网站免费久久| 岛国一区二区在线观看| 一本色道久久综合亚洲精品按摩| 91国产精品成人| 日韩午夜激情视频| 欧美激情综合网| 亚洲狼人国产精品| 精品在线播放午夜| 国产剧情在线观看一区二区| 麻豆一区二区三区| 偷拍日韩校园综合在线| 91精品综合久久久久久| 麻豆91精品视频| 91女厕偷拍女厕偷拍高清| 成人午夜免费电影| 一本久久综合亚洲鲁鲁五月天 | 成熟亚洲日本毛茸茸凸凹| 国产精品久线观看视频| 99久久精品99国产精品| 国产精品免费aⅴ片在线观看| 久久综合网色—综合色88| 99久久久久免费精品国产 | 在线视频欧美区| 国产亚洲一区二区在线观看| 最新中文字幕一区二区三区| 亚洲国产精品自拍| 成人黄色av电影| 亚洲乱码中文字幕| 日韩影院在线观看| 自拍偷自拍亚洲精品播放| 国产又黄又大久久| 中文字幕巨乱亚洲| 欧美肥妇毛茸茸| 国产综合色产在线精品| 91精品黄色片免费大全| 亚洲精品成人精品456| 成人午夜av影视| 欧美色网一区二区| 欧美激情一二三区| 欧美日韩在线播放三区四区| 一区二区三区鲁丝不卡| 欧美日韩国产成人在线免费| 国产精品二三区| 国产成人免费视频精品含羞草妖精 | 一本大道久久a久久精品综合| 日本一区二区三区在线不卡| 久久丁香综合五月国产三级网站| 欧美无砖专区一中文字| 国产乱码精品1区2区3区| 中文字幕在线不卡一区| 欧美麻豆精品久久久久久| 一区二区成人在线视频| 精品久久久久av影院| 欧美日韩午夜精品| 日欧美一区二区| 在线成人免费视频| 国产麻豆午夜三级精品| 91精彩视频在线| 日韩免费一区二区| 美脚の诱脚舐め脚责91| 亚洲日本一区二区三区| 欧美一区二区三区播放老司机 | 国产精品123区| 久久精品国产亚洲5555| 午夜av电影一区| 亚洲香肠在线观看| 五月激情综合色| 午夜精品福利在线| 日av在线不卡| 一区二区理论电影在线观看| 亚洲免费观看高清完整版在线观看| 亚洲视频一区在线观看| 亚洲va天堂va国产va久| 亚洲成av人片www| 奇米精品一区二区三区在线观看 | 欧美日免费三级在线| 国产成人h网站| 狠狠色综合色综合网络| 美女网站一区二区| 亚洲精选免费视频| 日本一区二区三区免费乱视频| 91黄色小视频| 欧美电视剧免费全集观看| 欧美日韩一区高清| 欧美手机在线视频| 国产精品影视网| 日本va欧美va欧美va精品| 玉足女爽爽91| 亚洲天堂2016| 国产精品无遮挡| 亚洲久草在线视频| 久久亚区不卡日本| 国产色产综合产在线视频| 国产精品久久久久久久久久久免费看 | 久久精品999| 不卡一区在线观看| 欧美日韩视频在线第一区| caoporn国产精品| 日韩免费视频一区二区| 日本一区二区视频在线观看| 日韩va亚洲va欧美va久久| 国产精品一品二品| 欧美日韩久久久一区| 国产欧美精品一区二区色综合| 一级女性全黄久久生活片免费| 麻豆精品一区二区| 91视频你懂的| 欧美精品一区在线观看| 国产精品第一页第二页第三页| 久久精品二区亚洲w码| 91在线无精精品入口| 91精品在线免费| 一片黄亚洲嫩模| 国产福利91精品一区二区三区| 91.com在线观看| 日韩毛片一二三区| 91精品国产欧美一区二区18| 中文字幕欧美日韩一区| 国产乱码精品一区二区三区五月婷| 欧美二区三区的天堂| 亚洲女同女同女同女同女同69| 欧美a级理论片| 91理论电影在线观看| 欧美激情一区二区三区四区| 国产一区二区三区日韩| 欧美日韩国产综合久久| 一区二区免费视频| 欧美综合色免费| 亚洲在线视频网站| 日本电影欧美片| 久久久噜噜噜久噜久久综合| 一区二区在线看| 国产精品欧美极品| 国产一区二区三区蝌蚪| 欧美美女一区二区三区| 一区二区三区欧美| 久久久久久久久久久电影| 亚洲福利视频一区| 欧美日韩一区二区在线视频| 国产福利一区二区三区| 精品福利在线导航| 久久精品国产免费| 久久精品一区二区三区不卡| 综合久久久久久久| 水蜜桃久久夜色精品一区的特点 | 亚洲激情在线播放| 一本大道av一区二区在线播放| 国产精品久久久久久久蜜臀| 国产成人综合网| 中文字幕亚洲电影| 不卡区在线中文字幕| 日韩欧美在线观看一区二区三区| 日韩成人av影视| 欧美一区二区三区啪啪| 久久亚洲一区二区三区四区| 国产成人亚洲综合a∨猫咪| 精品人在线二区三区| 粉嫩在线一区二区三区视频| 国产精品人妖ts系列视频| 成人激情黄色小说| 亚洲欧美一区二区三区久本道91 | 免费欧美日韩国产三级电影| 欧美日韩综合色| 丝袜亚洲另类丝袜在线| 欧美一区二区三区视频| 免费观看一级特黄欧美大片| 亚洲第一电影网| 欧美国产精品专区|