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

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

?? os_sem.c

?? ucos-ii在msp430f149上的移植
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                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;
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合激情另类小说区| 国产最新精品精品你懂的| 在线国产电影不卡| 日本美女一区二区三区视频| 精品对白一区国产伦| 成人黄页毛片网站| 亚洲gay无套男同| 久久久久成人黄色影片| 91蜜桃在线免费视频| 日韩影视精彩在线| 国产精品初高中害羞小美女文| 在线日韩av片| 不卡av电影在线播放| 天堂av在线一区| 亚洲国产精品高清| 日韩欧美色综合| 欧美日韩国产另类不卡| 93久久精品日日躁夜夜躁欧美| 青青草97国产精品免费观看 | 美腿丝袜在线亚洲一区| 日韩精品中文字幕在线一区| av网站一区二区三区| 在线观看欧美精品| 日韩精品影音先锋| 国产精品高潮久久久久无| 欧美日韩aaa| 成人激情图片网| 国产一区二区三区最好精华液| 亚洲国产日韩在线一区模特 | 国产寡妇亲子伦一区二区| 国产精品福利一区二区三区| 欧美日韩久久不卡| 成人短视频下载| 激情文学综合插| 日本aⅴ免费视频一区二区三区| 亚洲最新视频在线观看| 18成人在线观看| 亚洲欧美国产三级| 五月天精品一区二区三区| 蜜臀久久99精品久久久画质超高清| 一区二区三区国产豹纹内裤在线| 中文字幕一区二区三区四区不卡| 国产欧美日韩一区二区三区在线观看| 国产欧美日韩麻豆91| 国产精品视频第一区| 亚洲男同性视频| 视频一区国产视频| 国产一区二区不卡在线| 99精品久久只有精品| 欧美人妖巨大在线| 欧美国产精品劲爆| 日韩精品1区2区3区| jlzzjlzz亚洲女人18| 91超碰这里只有精品国产| 中国av一区二区三区| 日韩国产欧美三级| 欧美日韩精品三区| 国产精品国产三级国产普通话99| 国产精品综合在线视频| 国产精品免费av| 欧美视频一区二区在线观看| av中文一区二区三区| 国产九九视频一区二区三区| 日韩三级中文字幕| 国产精品白丝av| 欧美肥大bbwbbw高潮| 精品国产乱码久久久久久久| 亚洲伊人色欲综合网| 亚洲免费观看高清| 成年人午夜久久久| 国产偷国产偷精品高清尤物| 精品亚洲成a人| 国产欧美日韩在线| 欧美久久久一区| 国产成人高清视频| 午夜精品久久久久久久久久久| 久久久亚洲精华液精华液精华液 | 国产精品一区二区免费不卡| 大白屁股一区二区视频| 99久久精品久久久久久清纯| 欧美亚洲国产一区在线观看网站| 91精品福利视频| 欧美日韩1234| 亚洲激情五月婷婷| 在线观看三级视频欧美| 欧美一级在线免费| 国产欧美日韩另类一区| 欧美午夜在线一二页| 亚洲色图丝袜美腿| 国内一区二区视频| 日韩一级高清毛片| 国产成+人+日韩+欧美+亚洲| 色婷婷一区二区三区四区| 欧洲av在线精品| 国产人久久人人人人爽| 国产福利一区二区| 日本成人在线看| 欧美亚洲日本一区| 国产精品久久久一本精品| 一区二区三区日本| 欧美少妇性性性| 欧美在线观看你懂的| 国产99久久精品| a4yy欧美一区二区三区| 成年人国产精品| 在线观看国产一区二区| 91精品午夜视频| 国产无一区二区| 一片黄亚洲嫩模| 精品一区二区影视| 成人精品高清在线| 亚洲6080在线| 亚洲欧美日韩在线| 日本一区二区三区四区| 日本一区二区三区四区| 国产日韩欧美麻豆| 亚洲蜜臀av乱码久久精品| 国产夜色精品一区二区av| 欧美在线不卡一区| 中文字幕综合网| 99久久伊人网影院| 精品国产免费久久| 精品国产欧美一区二区| 色国产精品一区在线观看| 亚洲国产中文字幕在线视频综合 | 欧美一级片在线| 精品国产123| 亚洲精品一卡二卡| 视频一区二区三区入口| 精品一区二区三区久久久| 国产91在线观看| 国精产品一区一区三区mba桃花 | 久久精品国产精品亚洲红杏| 美女mm1313爽爽久久久蜜臀| 国产在线乱码一区二区三区| 北岛玲一区二区三区四区| 色菇凉天天综合网| 精品久久久久久久久久久久久久久久久 | 天天影视涩香欲综合网| 色噜噜狠狠色综合中国| 精品一区二区三区的国产在线播放| 亚洲精品水蜜桃| 精品成人一区二区三区四区| 中文字幕亚洲不卡| 全部av―极品视觉盛宴亚洲| 麻豆精品在线视频| 国内精品国产成人国产三级粉色| 亚洲蜜臀av乱码久久精品蜜桃| 欧美极品美女视频| 日本一区二区在线不卡| 色综合久久久久久久久| 91精品国产欧美一区二区成人| 日韩亚洲欧美综合| 欧美电影免费观看高清完整版 | 岛国一区二区在线观看| 9191成人精品久久| 一区二区在线观看免费视频播放| 另类调教123区| 欧美老女人第四色| 亚洲va欧美va国产va天堂影院| 91片黄在线观看| 一区二区在线电影| 国产99久久久国产精品潘金| 欧美人xxxx| 久久99精品久久久久久久久久久久 | 4438x成人网最大色成网站| 一区二区三区在线播| 欧美三级乱人伦电影| 午夜av区久久| 久久亚洲欧美国产精品乐播| 久久成人免费网| 国产欧美日韩精品在线| 色综合久久99| 日本美女视频一区二区| 国产亚洲综合在线| 91一区一区三区| 免费亚洲电影在线| 国产欧美日产一区| 欧美精品丝袜久久久中文字幕| 日产精品久久久久久久性色| 欧美国产精品专区| 欧美精品亚洲二区| 99久久99久久精品免费看蜜桃| 一区二区三区免费网站| 久久综合九色欧美综合狠狠| 成人app在线| 国产成人一级电影| 日本伊人色综合网| 亚洲人成在线播放网站岛国| 91精品久久久久久久久99蜜臂| 国产酒店精品激情| 日本欧美一区二区| 亚洲一区二区3| 综合欧美亚洲日本| 国产蜜臀97一区二区三区| 欧美伦理影视网| 欧美性xxxxxxxx| 在线区一区二视频| 欧美日韩三级在线| 欧美日韩在线电影|