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

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

?? os_sem.c

?? UCOSII在STM32平臺的移植
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.85
*
* LICENSING TERMS:
* ---------------
*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
* If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
* its use in your product. We provide ALL the source code for your convenience and to help you experience 
* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
* licensing fee.
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
//#include <ucos_ii.h>
#include  "..\..\uCOS-II\Source\ucos_ii.h"
#endif

#if OS_SEM_EN > 0
/*$PAGE*/
/*
*********************************************************************************************************
*                                           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 = 0;
#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 block (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 = 0;
#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.
*
*              perr          is a pointer to an error code that can contain one of the following values:
*                            OS_ERR_NONE             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 *perr)
{
    BOOLEAN    tasks_waiting;
    OS_EVENT  *pevent_return;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                              /* Validate 'perr'                          */
        return (pevent);
    }
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *perr = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *perr = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *perr = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore    */
        tasks_waiting = OS_TRUE;                           /* Yes                                      */
    } else {
        tasks_waiting = OS_FALSE;                          /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == OS_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();
                 *perr                  = OS_ERR_NONE;
                 pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *perr                  = OS_ERR_TASK_WAITING;
                 pevent_return          = pevent;
             }
             break;

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0) {             /* Ready ALL tasks waiting for semaphore    */
                 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
             }
#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 == OS_TRUE) {               /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *perr                  = OS_ERR_NONE;
             pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted               */
             break;

        default:
             OS_EXIT_CRITICAL();
             *perr                  = OS_ERR_INVALID_OPT;
             pevent_return          = pevent;
             break;
    }
    return (pevent_return);
}
#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).
*
*              perr          is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_ERR_NONE         The call was successful and your task owns the resource
*                                                or, the event you are waiting for occurred.
*                            OS_ERR_TIMEOUT      The semaphore was not received within the specified
*                                                'timeout'.
*                            OS_ERR_PEND_ABORT   The wait on the semaphore was aborted.
*                            OS_ERR_EVENT_TYPE   If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer.
*                            OS_ERR_PEND_LOCKED  If you called this function when the scheduler is locked
*
* Returns    : none
*********************************************************************************************************
*/

void  OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)
{
    INT8U      pend_stat;
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                         /* Validate 'perr'                               */
        return;
    }
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        *perr = OS_ERR_PEVENT_NULL;
        return;
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        *perr = OS_ERR_EVENT_TYPE;
        return;
    }
    if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
        *perr = OS_ERR_PEND_ISR;                      /* ... can't PEND from an ISR                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产午夜精品一区二区三区四区| av亚洲产国偷v产偷v自拍| 经典三级视频一区| 成a人片国产精品| 在线观看日韩国产| 欧美成人一区二区三区片免费| 久久精品一区二区三区不卡| 亚洲久本草在线中文字幕| 日韩福利视频导航| 国产成人免费视频一区| 在线观看欧美黄色| 久久久久久免费网| 亚洲综合视频在线| 国产高清亚洲一区| 欧美手机在线视频| 中文一区一区三区高中清不卡| 亚洲影院在线观看| 国产一区二区在线影院| 欧美优质美女网站| 久久久另类综合| 婷婷综合在线观看| 成人免费视频网站在线观看| 在线电影院国产精品| 亚洲国产精品国自产拍av| 天天色天天操综合| www.亚洲精品| 日韩欧美国产精品| 亚洲一区二三区| 国产mv日韩mv欧美| 欧美一级久久久久久久大片| 亚洲色图制服诱惑 | 在线视频国内自拍亚洲视频| 日韩精品一区二区三区在线播放| 玉米视频成人免费看| 国产成人精品一区二区三区四区 | 依依成人精品视频| 国产麻豆精品久久一二三| 欧美日韩中文字幕一区二区| 国产精品拍天天在线| 蜜芽一区二区三区| 在线看日韩精品电影| 国产精品乱人伦| 国产在线精品不卡| 日韩写真欧美这视频| 亚洲一卡二卡三卡四卡无卡久久| 成人性生交大片免费看中文网站| 日韩三级视频中文字幕| 亚洲综合激情另类小说区| 成人v精品蜜桃久久一区| 久久亚洲精品小早川怜子| 婷婷中文字幕综合| 欧美中文字幕一二三区视频| 亚洲免费资源在线播放| 成人a级免费电影| 国产午夜亚洲精品理论片色戒 | 欧美成人激情免费网| 天天影视色香欲综合网老头| 91毛片在线观看| 国产精品理论片| 成人精品gif动图一区| 久久久不卡网国产精品二区| 久久99精品一区二区三区三区| 欧美一区二区免费视频| 污片在线观看一区二区| 欧美日韩免费一区二区三区 | 欧美日韩亚洲综合在线| 玉米视频成人免费看| 91麻豆免费看片| 亚洲日本电影在线| 91网上在线视频| 中文字幕欧美一| 色综合咪咪久久| 一区二区在线免费观看| 色综合久久88色综合天天 | 欧美日韩性生活| 亚洲成va人在线观看| 欧美日韩中文字幕一区二区| 天堂一区二区在线免费观看| 欧美日韩国产a| 秋霞成人午夜伦在线观看| 欧美一区二区三区视频在线| 蜜臀精品一区二区三区在线观看 | 日韩国产精品久久| 欧美一区二区精品久久911| 日本不卡中文字幕| 日韩你懂的在线播放| 美女视频黄久久| 久久影院午夜论| 成人午夜短视频| 国产精品久久777777| 色婷婷香蕉在线一区二区| 亚洲国产精品一区二区www| 欧美日韩国产一级片| 免费日韩伦理电影| 久久久久久一级片| 99精品欧美一区| 亚洲一区二区精品久久av| 欧美一区二区三区不卡| 国产乱子伦视频一区二区三区| 国产午夜三级一区二区三| 91色乱码一区二区三区| 亚洲国产精品久久久男人的天堂 | 黄色日韩网站视频| 中文字幕不卡的av| 欧美中文字幕一二三区视频| 麻豆国产一区二区| 亚洲国产精品二十页| 欧美性大战久久久| 极品少妇一区二区| 综合久久给合久久狠狠狠97色| 欧美日韩成人在线| 激情图片小说一区| 亚洲欧洲国产日韩| 91精品国产综合久久蜜臀| 国产精品综合视频| 亚洲最大成人网4388xx| 日韩免费视频一区二区| 成人av网站在线观看免费| 午夜天堂影视香蕉久久| 久久亚洲一区二区三区明星换脸| 色综合一个色综合| 欧美日精品一区视频| 久久福利视频一区二区| 国产精品国产a| 91精品黄色片免费大全| 不卡在线视频中文字幕| 日韩 欧美一区二区三区| 中文字幕在线一区免费| 91精品欧美福利在线观看| 成人黄色软件下载| 日韩不卡手机在线v区| 国产精品美女视频| 91精品黄色片免费大全| 91污在线观看| 激情小说亚洲一区| 亚洲成在线观看| 国产精品视频你懂的| 91精品国产色综合久久ai换脸| 粉嫩av一区二区三区| 日本在线不卡一区| 日韩理论片在线| 久久一留热品黄| 91精品一区二区三区久久久久久 | 中文字幕一区三区| 日韩欧美高清在线| 欧美视频在线播放| 成人白浆超碰人人人人| 韩国精品在线观看| 视频一区二区国产| 亚洲人成网站色在线观看| 久久人人97超碰com| 欧美三级中文字幕| 91视频在线观看免费| 国产盗摄女厕一区二区三区 | 精品福利在线导航| 欧美日韩不卡视频| 91成人网在线| 91影院在线免费观看| 国产91精品入口| 麻豆91在线观看| 五月婷婷久久丁香| 亚洲午夜私人影院| 亚洲色图制服诱惑| 国产精品久久久久久久久免费相片| 精品国产伦理网| 欧美一级在线观看| 欧美日韩精品电影| 欧美色精品在线视频| 色综合久久久久综合体 | 一区二区三区四区蜜桃| 1024成人网色www| 中文字幕欧美一| 最新久久zyz资源站| 久久精品欧美一区二区三区不卡| 奇米一区二区三区av| 日日骚欧美日韩| 天天爽夜夜爽夜夜爽精品视频| 午夜精品一区二区三区电影天堂| 亚洲午夜日本在线观看| 一级精品视频在线观看宜春院| 亚洲日本va在线观看| 亚洲精品乱码久久久久久黑人| 自拍偷拍亚洲欧美日韩| 亚洲男人的天堂网| 亚洲精品免费在线播放| 亚洲一区自拍偷拍| 亚洲h动漫在线| 日本女优在线视频一区二区| 日本不卡一二三| 久久91精品久久久久久秒播| 精品一区二区三区日韩| 国内精品免费**视频| 国产精品原创巨作av| 国产成人在线免费| 不卡的av电影| 在线观看一区不卡| 56国语精品自产拍在线观看| 日韩午夜av一区| 精品欧美久久久| 亚洲国产精品黑人久久久|