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

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

?? os_sem.c

?? 飛思卡爾HCS12的OS移植(ucosII),實現了三個任務,IDE:CODEWARRIOR
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                              (c) Copyright 1992-2007, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_SEM.C
* By      : Jean J. Labrosse
* Version : V2.86
*
* 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一区二区三区免费野_久草精品视频
久久久久88色偷偷免费| 99精品一区二区| 精品女同一区二区| 韩国三级中文字幕hd久久精品| wwww国产精品欧美| 国产精品一线二线三线精华| 中国色在线观看另类| 91啪亚洲精品| 日韩黄色免费网站| 久久亚洲影视婷婷| 91性感美女视频| 香蕉久久一区二区不卡无毒影院 | 日本在线不卡一区| 日韩欧美另类在线| 成人国产精品免费观看动漫| 一区二区三区精品视频| 91麻豆精品国产91久久久久久久久 | 亚洲人吸女人奶水| 91精品国产综合久久久久| 国产高清在线精品| 亚洲国产精品综合小说图片区| 欧美大片国产精品| 日本久久精品电影| 久久99精品国产麻豆婷婷| 亚洲色图一区二区| 精品久久久久99| 色吊一区二区三区| 国产精品456露脸| 香蕉成人啪国产精品视频综合网| 久久中文娱乐网| 欧美日韩一卡二卡| 成人av高清在线| 美女性感视频久久| 一二三区精品福利视频| 精品国产成人系列| 欧美日韩一区不卡| jizzjizzjizz欧美| 韩国成人在线视频| 午夜久久久影院| 亚洲欧洲99久久| 欧美大白屁股肥臀xxxxxx| 一本色道久久加勒比精品| 国产成人午夜电影网| 日本不卡不码高清免费观看| 一区二区三区四区在线免费观看| 久久色成人在线| 91麻豆精品国产91久久久久久久久| 不卡av在线网| 国产精品影音先锋| 久久精品国产亚洲一区二区三区| 一区二区三区在线视频免费 | 精品国产a毛片| 91福利国产成人精品照片| 国产成人午夜视频| 国产一区在线精品| 久久精品国产999大香线蕉| 五月天丁香久久| 亚洲第一久久影院| 一区二区在线观看不卡| 中文字幕视频一区| 国产精品乱人伦| 国产视频在线观看一区二区三区| 精品久久久久久无| 精品少妇一区二区三区在线播放 | 亚洲日本在线看| 国产精品嫩草99a| 久久精品夜色噜噜亚洲a∨| 欧美mv日韩mv国产网站app| 日韩一卡二卡三卡四卡| 91精品国产福利| 91精品国产综合久久久久久久久久 | 日韩欧美激情在线| 日韩一区二区三区免费观看| 51久久夜色精品国产麻豆| 欧美老肥妇做.爰bbww视频| 欧美性淫爽ww久久久久无| 精品视频色一区| 欧美一区二视频| 欧美va亚洲va香蕉在线| 久久亚洲春色中文字幕久久久| 久久亚区不卡日本| 久久久久国产免费免费| 国产拍欧美日韩视频二区| 国产精品免费免费| 亚洲美女免费视频| 视频在线在亚洲| 九一久久久久久| 国产成人aaa| 色先锋资源久久综合| 欧美丝袜丝交足nylons| 91精品国产美女浴室洗澡无遮挡| 欧美成人激情免费网| 久久精品欧美日韩| 亚洲欧美成aⅴ人在线观看| 亚洲一级二级三级在线免费观看| 日韩国产欧美在线播放| 国产精品自拍网站| aaa欧美大片| 欧美日韩视频在线一区二区| 日韩限制级电影在线观看| 欧美韩国一区二区| 夜夜嗨av一区二区三区四季av| 日日夜夜免费精品| 国产白丝网站精品污在线入口| 色伊人久久综合中文字幕| 欧美一区二区播放| 中文字幕精品三区| 亚洲超碰精品一区二区| 国产高清在线精品| 在线免费精品视频| 26uuu精品一区二区在线观看| 自拍偷在线精品自拍偷无码专区 | 在线免费观看日韩欧美| 欧美成人免费网站| 亚洲精品国产成人久久av盗摄| 日韩福利电影在线| 波多野结衣视频一区| 日韩一区二区三区电影在线观看| 国产精品久久久久婷婷二区次| 亚洲第一会所有码转帖| 国产成人精品免费在线| 欧美日韩精品欧美日韩精品| 欧美激情在线看| 美女一区二区三区在线观看| 91美女片黄在线| 精品国产精品网麻豆系列 | 国产精品成人网| 精油按摩中文字幕久久| 91精彩视频在线观看| 日韩精品一区二区三区中文不卡 | 国产suv精品一区二区883| 欧美猛男超大videosgay| 国产精品热久久久久夜色精品三区| 天堂久久一区二区三区| av在线不卡免费看| 久久人人爽爽爽人久久久| 亚洲成国产人片在线观看| 波多野结衣亚洲一区| 久久久噜噜噜久噜久久综合| 日韩精彩视频在线观看| 97精品超碰一区二区三区| 久久亚洲一区二区三区四区| 日本vs亚洲vs韩国一区三区| 色乱码一区二区三区88| 国产精品免费视频观看| 国内精品国产三级国产a久久 | 欧美性高清videossexo| 国产精品二区一区二区aⅴ污介绍| 国内精品视频666| 日韩精品中午字幕| 日日噜噜夜夜狠狠视频欧美人| 91年精品国产| 国产精品福利电影一区二区三区四区| 韩国av一区二区三区在线观看| 欧美一区二区三区男人的天堂| 亚洲国产另类av| 欧美日韩一区不卡| 亚洲不卡在线观看| 91 com成人网| 奇米色777欧美一区二区| 欧美精品在欧美一区二区少妇| 一区二区三区在线免费视频| 日本精品一区二区三区高清| 亚洲日本丝袜连裤袜办公室| 99这里都是精品| 亚洲色图欧美在线| 色婷婷综合五月| 亚洲成人在线免费| 7777精品伊人久久久大香线蕉完整版| 亚洲一区二区三区四区在线| 欧美午夜精品久久久久久超碰| 亚洲综合在线观看视频| 欧美日韩一区二区电影| 日韩在线a电影| 日韩欧美国产精品| 国产成人在线看| 国产精品久久久久久亚洲毛片 | 欧美国产欧美综合| 9人人澡人人爽人人精品| 一区二区在线观看不卡| 欧美一区欧美二区| 国产乱子伦一区二区三区国色天香| 国产日产欧美一区二区视频| 99精品偷自拍| 午夜精品福利在线| 精品国产亚洲在线| 99国产精品国产精品久久| 亚洲成人三级小说| 欧美xxxx老人做受| 成人av在线资源| 天天射综合影视| 久久久久久久久久看片| 色又黄又爽网站www久久| 日本成人在线看| 国产人成亚洲第一网站在线播放| 色琪琪一区二区三区亚洲区| 丝袜美腿亚洲综合| 国产精品久久久久四虎| 欧美精品成人一区二区三区四区| 久久机这里只有精品|