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

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

?? os_sem.c

?? ucosII在ATmega16上的移植源碼.rar
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.76
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "ucos_ii.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)
{
    INT16U     cnt;
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                       /* Prevent compiler warning                      */
#endif    
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
    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)
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    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                */
#if OS_EVENT_NAME_SIZE > 1
        pevent->OSEventName[0] = '?';                      /* Unknown name                             */
        pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
        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)
{
    BOOLEAN    tasks_waiting;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;



    cpu_sr = 0;                                            /* Prevent compiler warning                 */
#endif    
    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);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    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) {
#if OS_EVENT_NAME_SIZE > 1
                 pevent->OSEventName[0] = '?';             /* Unknown name                             */
                 pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
                 pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free list  */
                 pevent->OSEventCnt     = 0;
                 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    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
#if OS_EVENT_NAME_SIZE > 1
             pevent->OSEventName[0] = '?';                 /* Unknown name                             */
             pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
             pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free list  */
             pevent->OSEventCnt     = 0;
             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);
    }
}
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                           PEND ON SEMAPHORE
*
* Description: This function waits for a semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            semaphore.
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for the resource up to the amount of time specified by this argument.
*                            If you specify 0, however, your task will wait forever at the specified
*                            semaphore or, until the resource becomes available (or the event occurs).
*
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费av在线| 粉嫩aⅴ一区二区三区四区| 久久精品国产999大香线蕉| 成人免费av在线| 欧美成人高清电影在线| 亚洲自拍与偷拍| 成人va在线观看| 久久婷婷国产综合精品青草| 亚洲日本免费电影| 成人一道本在线| 久久久久久久综合狠狠综合| 日韩成人一级大片| 欧美在线999| 亚洲精品老司机| 97精品视频在线观看自产线路二| 久久久亚洲高清| 精品在线免费观看| 精品视频在线免费看| 亚洲人成7777| 99re视频精品| 亚洲色图20p| 91女厕偷拍女厕偷拍高清| 日本一区二区三区四区在线视频| 国模一区二区三区白浆 | 亚洲精品第1页| 成人av在线观| 欧美韩日一区二区三区四区| 国内外成人在线| 久久久亚洲高清| 精品在线视频一区| 精品成人一区二区| 久久精品99国产国产精| 精品国产乱码久久久久久影片| 日韩高清中文字幕一区| 欧美一级免费观看| 麻豆国产一区二区| 久久综合久久99| 国产毛片精品一区| 国产欧美精品区一区二区三区| 国产精品一品视频| 中文字幕色av一区二区三区| 91麻豆国产精品久久| 一区二区欧美在线观看| 欧美日韩一级二级三级| 毛片基地黄久久久久久天堂| 久久亚洲私人国产精品va媚药| 国产精品一区二区男女羞羞无遮挡| 国产日韩欧美精品一区| 日韩午夜av一区| 国产传媒久久文化传媒| 国产最新精品免费| 久久精品视频一区二区| 成人av电影免费观看| 亚洲素人一区二区| 91超碰这里只有精品国产| 蜜臀久久久久久久| 亚洲国产精品成人综合 | 国产精品理论片| 色偷偷久久一区二区三区| 婷婷综合另类小说色区| 日韩欧美亚洲国产精品字幕久久久| 国内精品国产三级国产a久久| 久久久久久久久久久电影| 91在线一区二区三区| 日日夜夜免费精品| 日本一区二区在线不卡| 欧美日韩一区在线观看| 国产精品亚洲成人| 亚洲午夜在线电影| 国产亚洲成年网址在线观看| 欧美日韩免费不卡视频一区二区三区| 亚洲观看高清完整版在线观看| 精品三级av在线| 在线视频你懂得一区二区三区| 久久99久久久欧美国产| 亚洲欧美国产77777| 欧美精品一区二区三区一线天视频| 成人国产一区二区三区精品| 日韩精品亚洲一区| 1000精品久久久久久久久| 欧美大白屁股肥臀xxxxxx| 91毛片在线观看| 国产麻豆成人精品| 日韩不卡一区二区| 一区二区久久久久久| 日本一区二区三区四区在线视频| 欧美久久久久久久久久| 91女厕偷拍女厕偷拍高清| 国产一区二区电影| 日本一道高清亚洲日美韩| 玉米视频成人免费看| 欧美极品少妇xxxxⅹ高跟鞋 | 久久精品一区八戒影视| 欧美一级国产精品| 欧美群妇大交群的观看方式| 色综合一区二区| 高清日韩电视剧大全免费| 久久国产精品无码网站| 香蕉成人啪国产精品视频综合网| 自拍偷拍国产亚洲| 国产精品电影一区二区| 日本一区二区三区dvd视频在线| 日韩一区二区在线看| 欧美日韩久久不卡| 精品视频一区二区不卡| 91九色最新地址| 成人免费毛片a| 成人激情电影免费在线观看| 国产成人av一区二区三区在线| 狂野欧美性猛交blacked| 天堂久久一区二区三区| 日韩精品三区四区| 日韩av在线发布| 麻豆精品新av中文字幕| 久久国产乱子精品免费女| 美国一区二区三区在线播放| 欧美aaa在线| 久久99国内精品| 韩国理伦片一区二区三区在线播放| 日韩精品一二三区| 久久精品免费观看| 国产麻豆成人传媒免费观看| 国产成人综合视频| av欧美精品.com| 欧美伊人久久久久久久久影院| 欧美三级日韩在线| 精品嫩草影院久久| 日韩视频一区二区三区在线播放| 91精品婷婷国产综合久久竹菊| 在线不卡一区二区| 亚洲精品一区二区三区香蕉| 欧美激情艳妇裸体舞| 亚洲三级理论片| 日韩和的一区二区| 国产精品亚洲人在线观看| av电影在线观看完整版一区二区| 色偷偷久久人人79超碰人人澡| 欧美喷水一区二区| 久久久久久久久久久久久久久99 | 欧美日韩夫妻久久| 精品国产亚洲一区二区三区在线观看| 久久综合久久99| 伊人开心综合网| 热久久国产精品| 成人教育av在线| 欧美日韩国产小视频| 久久综合给合久久狠狠狠97色69| 国产精品久久久久久久第一福利 | 国产精品国产a级| 一区二区三区日韩欧美精品| 美女诱惑一区二区| 不卡的av电影| 日韩精品自拍偷拍| 亚洲欧美日韩在线不卡| 开心九九激情九九欧美日韩精美视频电影 | 日韩精品午夜视频| 成人免费视频一区| 欧美一区二区三区在线视频| 亚洲欧美自拍偷拍色图| 美女www一区二区| 欧美综合一区二区| 国产女主播在线一区二区| 日韩中文字幕一区二区三区| 成人精品一区二区三区中文字幕| 欧美乱熟臀69xxxxxx| 国产精品传媒视频| 另类综合日韩欧美亚洲| 91国内精品野花午夜精品| 久久久国产午夜精品| 日日摸夜夜添夜夜添精品视频| 国产不卡一区视频| 日韩视频不卡中文| 午夜视频在线观看一区二区| 成人福利视频在线| 久久久一区二区三区捆绑**| 日韩二区在线观看| 欧美艳星brazzers| 亚洲三级在线免费| 成人av中文字幕| 国产亚洲一区二区三区| 奇米色一区二区| 欧美三级电影网| 亚洲激情图片小说视频| 成人性生交大片免费看在线播放| 欧美成人高清电影在线| 日本美女一区二区| 欧美日韩高清不卡| 亚洲va欧美va人人爽| 91福利精品视频| 亚洲美女淫视频| 91原创在线视频| 亚洲欧美日韩久久| 91免费视频大全| 综合久久久久久久| 91污在线观看| 亚洲品质自拍视频| 91极品视觉盛宴| 亚洲成人综合在线| 欧美日韩国产精选| 日韩精品久久久久久|