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

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

?? os_sem.c

?? 簡單的在ATMEGA64上移植ucosII
?? 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一区二区三区免费野_久草精品视频
激情另类小说区图片区视频区| 精品剧情在线观看| 日韩精品久久久久久| 久久精品一区二区三区不卡| 日本韩国精品一区二区在线观看| 精品中文字幕一区二区| 亚洲欧美视频在线观看视频| 久久精品欧美日韩| 欧美一级免费观看| 91美女片黄在线观看| 国产一区二区在线观看视频| 日韩极品在线观看| 亚洲精品中文在线观看| 国产欧美va欧美不卡在线| 日韩精品一区二区三区视频播放| 99re视频精品| 国产夫妻精品视频| 午夜久久久久久久久久一区二区| 中文欧美字幕免费| 2023国产精品| 日韩欧美成人激情| 欧美日韩大陆在线| 欧美日韩久久久一区| 激情图片小说一区| 香蕉久久一区二区不卡无毒影院 | 色综合一区二区| 国产乱码字幕精品高清av | 国产精品毛片无遮挡高清| 日韩区在线观看| 337p亚洲精品色噜噜狠狠| 色欧美88888久久久久久影院| 成人综合激情网| 国产69精品久久777的优势| 国产在线精品免费av| 精品一区二区免费看| 麻豆精品在线看| 精品一区二区三区av| 精品在线观看视频| 91美女在线视频| 亚洲精品视频免费观看| 777午夜精品免费视频| 欧美日韩午夜影院| 4438x亚洲最大成人网| 欧美精品久久天天躁| 91精品国产综合久久久久久久久久 | 色综合久久综合中文综合网| 91麻豆精品秘密| 在线欧美日韩精品| 欧美日韩一级二级三级| 欧美日韩国产电影| 日韩欧美激情在线| 久久夜色精品一区| 中文字幕国产一区| 亚洲人成7777| 亚洲伊人伊色伊影伊综合网| 亚洲国产日韩在线一区模特| 日日摸夜夜添夜夜添亚洲女人| 日本人妖一区二区| 国产成人亚洲综合a∨婷婷图片| 成人高清免费观看| 欧美最新大片在线看| 91精选在线观看| 精品噜噜噜噜久久久久久久久试看 | 天天射综合影视| 精品亚洲国内自在自线福利| 成人听书哪个软件好| 色八戒一区二区三区| 在线观看91精品国产麻豆| 日韩欧美自拍偷拍| 欧美国产日韩精品免费观看| 亚洲精品ww久久久久久p站| 丝袜美腿亚洲一区二区图片| 国内一区二区视频| 日韩美女在线视频 | 亚洲午夜电影在线| 91精品蜜臀在线一区尤物| 色综合久久中文综合久久97| 欧美日韩国产乱码电影| 精品国产青草久久久久福利| 国产精品久久久久久亚洲毛片| caoporn国产精品| 欧美在线免费播放| 久久综合九色综合97婷婷女人| 国产精品毛片无遮挡高清| 五月综合激情日本mⅴ| 国产宾馆实践打屁股91| 欧美精品一二三区| 国产精品乱码妇女bbbb| 五月天国产精品| 成人免费看黄yyy456| 欧美肥妇bbw| 国产精品久久久久婷婷二区次| 午夜国产精品一区| 不卡av电影在线播放| 91精品久久久久久蜜臀| 亚洲视频在线一区观看| 久久国产福利国产秒拍| 91精品福利视频| 欧美中文字幕一区二区三区| 99视频国产精品| 91精品国产乱码| 亚洲美女在线一区| 国产一区二区电影| 成人综合日日夜夜| 精品国产一区二区三区久久久蜜月 | 久久99蜜桃精品| 97精品国产露脸对白| 欧美xfplay| 午夜精品久久久久影视| 97精品超碰一区二区三区| 欧美电影免费观看高清完整版在线 | 久久久www免费人成精品| 一区二区不卡在线播放 | 国产在线精品视频| 777久久久精品| 国产福利一区二区三区视频在线| 一本一道波多野结衣一区二区| 日韩不卡免费视频| 91精品国产综合久久精品| 亚洲国产综合91精品麻豆| 亚洲高清免费一级二级三级| 99久久国产综合精品麻豆 | 日本一区二区视频在线观看| 日韩精品91亚洲二区在线观看| 欧美影片第一页| 亚洲天堂中文字幕| jiyouzz国产精品久久| 国产日韩欧美制服另类| 国产一二三精品| 精品国一区二区三区| 日本午夜一本久久久综合| 欧美日韩三级在线| 亚洲国产视频直播| 欧美中文字幕一区二区三区 | 欧美妇女性影城| 无码av免费一区二区三区试看| 欧美视频一区二区三区在线观看| 一区二区三区色| 欧美亚洲国产bt| 午夜久久久久久久久久一区二区| 欧美日韩国产一二三| 日韩一区精品字幕| 日韩欧美一卡二卡| 国内精品写真在线观看| 国产午夜亚洲精品午夜鲁丝片| 国产成人在线视频网址| 国产精品素人一区二区| 色综合久久综合| 亚洲va韩国va欧美va精品| 欧美一区二区久久久| 玖玖九九国产精品| 久久久久国产一区二区三区四区| 国产成人激情av| 国产精品免费看片| 91福利精品第一导航| 午夜影院在线观看欧美| 欧美v国产在线一区二区三区| 国产精品18久久久久久久久久久久| 国产欧美日韩视频一区二区| 99精品桃花视频在线观看| 一区二区三区久久久| 国产精品久久久久一区| 色妞www精品视频| 日韩不卡一区二区| 久久久99精品久久| 91九色02白丝porn| 捆绑调教美女网站视频一区| 国产精品国产三级国产普通话蜜臀 | 国产喷白浆一区二区三区| 成人avav在线| 亚洲高清一区二区三区| 久久久亚洲欧洲日产国码αv| 成人深夜在线观看| 亚洲第四色夜色| 久久久亚洲高清| 欧美色国产精品| 国产九色sp调教91| 一区二区三区日韩| 欧美精品一区二区三区在线| 91视频你懂的| 激情偷乱视频一区二区三区| 亚洲精品欧美二区三区中文字幕| 日韩欧美一区二区久久婷婷| 色综合天天狠狠| 狠狠网亚洲精品| 亚洲精品v日韩精品| 国产亚洲精品中文字幕| 欧美日韩精品一区二区三区四区| 国产毛片一区二区| 天天亚洲美女在线视频| 18欧美乱大交hd1984| 日韩欧美国产wwwww| 在线看日韩精品电影| 国产精品综合在线视频| 亚洲国产成人精品视频| 亚洲欧洲99久久| 久久亚洲春色中文字幕久久久| 欧美色倩网站大全免费| 99久久伊人精品| 国产在线精品视频|