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

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

?? os_sem.c

?? ucos-ii在msp430f149上的移植
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                              (c) Copyright 1992-2008, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.87
*
* 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"
#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
*********************************************************************************************************
*/
/*$PAGE*/
void  OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)
{
#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                    */
        return;
    }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品二十页| 91久久一区二区| 精品福利一二区| 蜜乳av一区二区| 精品国产伦一区二区三区免费 | 日韩欧美国产一区二区在线播放| 午夜精品福利视频网站| 91麻豆精品国产自产在线观看一区 | 制服视频三区第一页精品| 日韩国产高清影视| 欧美成人在线直播| 福利电影一区二区三区| 亚洲色图视频网站| 制服丝袜在线91| 岛国精品在线观看| 亚洲国产视频网站| 欧美精品一区二区三区高清aⅴ| 国产精品系列在线播放| 最新不卡av在线| 制服丝袜国产精品| www.欧美色图| 日韩高清在线一区| 国产免费观看久久| 欧美三级视频在线| 国产v日产∨综合v精品视频| 一区二区三区在线影院| 精品国产乱码91久久久久久网站| av一区二区三区四区| 日韩电影在线观看电影| 国产精品剧情在线亚洲| 欧美一级夜夜爽| 91在线观看视频| 老鸭窝一区二区久久精品| 国产精品电影院| 777xxx欧美| 91网址在线看| 激情综合一区二区三区| 亚洲一区二区三区四区不卡| 久久精品无码一区二区三区| 欧美三级电影精品| 成人免费视频caoporn| 三级影片在线观看欧美日韩一区二区| 欧美经典一区二区三区| 欧美大片拔萝卜| 欧美亚洲国产一区在线观看网站| 国产乱码精品一区二区三区av | 亚洲激情在线激情| 国产精品午夜免费| 精品国产三级电影在线观看| 欧美日韩综合在线| 色香蕉成人二区免费| 国产999精品久久久久久绿帽| 老鸭窝一区二区久久精品| 亚洲一区二区免费视频| 成人免费视频在线观看| 久久精品欧美一区二区三区不卡| 日韩午夜在线观看视频| 欧美色图一区二区三区| av在线这里只有精品| 成人永久aaa| 精品一区二区三区免费视频| 亚洲6080在线| 亚洲一区二区在线观看视频| 国产精品电影一区二区三区| 欧美激情资源网| 国产日产欧产精品推荐色| 久久尤物电影视频在线观看| 欧美一区二区视频在线观看2020| 欧美性极品少妇| 色婷婷激情一区二区三区| 成人高清免费观看| 丁香婷婷综合网| 床上的激情91.| 成人精品小蝌蚪| 成人黄色在线网站| fc2成人免费人成在线观看播放| 国产91在线看| 成人免费看视频| 99国产精品视频免费观看| 播五月开心婷婷综合| www.亚洲免费av| 色八戒一区二区三区| 日本韩国欧美一区| 欧美美女视频在线观看| 91精品一区二区三区久久久久久| 777a∨成人精品桃花网| 精品91自产拍在线观看一区| 久久免费的精品国产v∧| 亚洲国产精品国自产拍av| 1区2区3区国产精品| 一区二区激情视频| 日韩av一级片| 极品少妇xxxx偷拍精品少妇| 国产a视频精品免费观看| 91尤物视频在线观看| 欧美性极品少妇| 欧美变态tickling挠脚心| 中文乱码免费一区二区 | 亚洲成a人片综合在线| 蜜桃视频在线观看一区二区| 国产麻豆精品一区二区| bt欧美亚洲午夜电影天堂| 欧美日韩亚洲丝袜制服| 精品久久久久久综合日本欧美| 久久久国产一区二区三区四区小说| 国产欧美日韩激情| 亚洲午夜电影在线观看| 国内精品免费**视频| 日本黄色一区二区| 精品对白一区国产伦| 亚洲精品欧美激情| 久久99国内精品| 91热门视频在线观看| 日韩一区二区三区在线观看 | 精品国产91亚洲一区二区三区婷婷| 久久精品人人做| 午夜一区二区三区视频| 国产精品一区久久久久| 欧美色成人综合| 中文字幕在线观看一区| 青青青伊人色综合久久| 99re在线视频这里只有精品| 538在线一区二区精品国产| 中文字幕在线不卡一区| 久久99精品国产.久久久久| 在线观看日韩电影| 久久精品男人天堂av| 人禽交欧美网站| 色综合中文字幕国产| 欧美电视剧免费观看| 一区二区三区中文在线观看| 国产精品自拍在线| 91精品国产综合久久婷婷香蕉| 中文字幕在线观看不卡视频| 狠狠狠色丁香婷婷综合激情| 欧美日韩一区视频| 中文字幕日韩一区| 国产成人亚洲综合色影视| 91精品国产手机| 一区二区三区欧美激情| 成人av网站在线| 久久一夜天堂av一区二区三区| 日韩成人伦理电影在线观看| 欧美性受xxxx黑人xyx| 国产精品久久午夜夜伦鲁鲁| 激情综合网av| 91精品国产综合久久香蕉麻豆 | 亚洲婷婷综合久久一本伊一区| 精品亚洲porn| 日韩欧美不卡在线观看视频| 亚洲综合成人网| 91久久线看在观草草青青| 国产精品久久久久久久久免费桃花| 国产真实乱子伦精品视频| 91精品国产全国免费观看| 亚洲成av人片观看| 欧洲亚洲精品在线| 亚洲国产日产av| 欧美在线制服丝袜| 亚洲一区二区三区精品在线| 日本韩国精品在线| 亚洲午夜激情网页| 欧美日韩国产三级| 日韩国产精品久久久| 91精品国产欧美一区二区18| 日韩经典中文字幕一区| 欧美日韩国产一级二级| 婷婷丁香激情综合| 7777精品伊人久久久大香线蕉的 | 色一情一伦一子一伦一区| 亚洲欧美色图小说| 欧美性受xxxx黑人xyx性爽| 亚洲国产日韩综合久久精品| 欧美日韩一区二区三区高清 | 丁香婷婷综合色啪| 成人欧美一区二区三区小说| 色综合天天在线| 午夜精品福利久久久| 欧美一级专区免费大片| 国产一区二区三区蝌蚪| 中文字幕欧美区| 欧美亚洲动漫精品| 美女精品自拍一二三四| 国产天堂亚洲国产碰碰| 94-欧美-setu| 日韩不卡在线观看日韩不卡视频| 日韩欧美一区在线| 丁香啪啪综合成人亚洲小说| 一区二区三区免费看视频| 欧美精品少妇一区二区三区| 久久精品99国产精品日本| 中文字幕免费不卡| 欧美日韩一本到| 成人免费看片app下载| 日本高清不卡aⅴ免费网站| 欧美图片一区二区三区| 91浏览器在线视频| 91精品国产综合久久精品图片 | 成人一级片在线观看| 不卡电影一区二区三区|