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

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

?? os_sem.c

?? mega128-ucos285-gcc-avrstdio可以和proteus7.4sp3一起仿真的好東西
?? 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亚洲精品久久久蜜桃| 无码av中文一区二区三区桃花岛| 日本va欧美va精品| 日韩一区二区中文字幕| 色哟哟在线观看一区二区三区| 亚洲精品欧美二区三区中文字幕| 成人精品免费看| 亚洲一区二区三区自拍| 福利视频网站一区二区三区| 日韩一级在线观看| 亚洲午夜久久久久| 久久久久久9999| 国产精品自在欧美一区| 亚洲mv在线观看| 欧美三级中文字幕| 国产盗摄一区二区三区| 色综合亚洲欧洲| 久久久噜噜噜久久中文字幕色伊伊| 99re亚洲国产精品| 一区二区欧美视频| 理论电影国产精品| 国产一区二区不卡| 一道本成人在线| 国产成人精品一区二区三区网站观看| 亚洲欧美日韩综合aⅴ视频| 国产精品1区2区3区在线观看| 狂野欧美性猛交blacked| 精品国产a毛片| 亚洲精品v日韩精品| 91原创在线视频| 日本韩国一区二区| 成人av先锋影音| 国产91丝袜在线观看| 欧美日韩成人激情| 91精品国产手机| 91精品国产综合久久久蜜臀图片| 日韩精品一区二区三区四区| 亚洲欧美视频在线观看| 免费av成人在线| 亚洲精品国产成人久久av盗摄| 最近中文字幕一区二区三区| 97久久超碰国产精品电影| 97se狠狠狠综合亚洲狠狠| 欧亚一区二区三区| 国产日韩欧美制服另类| 亚洲一区二区三区小说| 一本大道久久a久久精二百| 丁香网亚洲国际| 成人综合在线观看| 精品一区二区免费在线观看| 日本欧美一区二区在线观看| 天使萌一区二区三区免费观看| 国产精品福利在线播放| 日韩码欧中文字| 久久久久久久久久久久久久久99| 一个色在线综合| 欧美喷潮久久久xxxxx| 激情综合网av| 欧美视频一区二区三区| 成人va在线观看| 日韩视频一区二区在线观看| 亚洲女厕所小便bbb| 国产精品中文字幕一区二区三区| 在线视频观看一区| 亚洲免费在线播放| 一本色道综合亚洲| 亚洲欧美另类在线| 欧美午夜精品免费| 日本三级韩国三级欧美三级| 精品婷婷伊人一区三区三| 伊人婷婷欧美激情| 91精品久久久久久久99蜜桃| 美女免费视频一区二区| 精品va天堂亚洲国产| 成人av在线影院| 一区二区三区成人在线视频| 欧美精品乱码久久久久久按摩| 日韩成人一级片| 国产精品另类一区| 欧美日韩国产首页| 成人免费视频国产在线观看| 精品久久久影院| 欧美精品一区二区三区很污很色的| 国产精品福利一区二区| 国内精品自线一区二区三区视频| 成人高清免费在线播放| 久久久久国产免费免费 | 4438x成人网最大色成网站| 欧美日韩精品三区| 欧美色男人天堂| 欧美一区二区三区免费视频 | 欧亚一区二区三区| 亚洲最快最全在线视频| 欧美成人精品二区三区99精品| 午夜欧美2019年伦理| 欧美精品亚洲一区二区在线播放| 久久亚洲综合av| 亚洲精品水蜜桃| 国产一区二区三区最好精华液| 91精品国产高清一区二区三区蜜臀| 麻豆成人久久精品二区三区红 | 欧美日韩国产高清一区二区| 国产999精品久久| 久久久久久久久久电影| 色狠狠色狠狠综合| 久久福利资源站| 国产高清无密码一区二区三区| 国产精品视频一二三| 成人高清伦理免费影院在线观看| 99久久精品久久久久久清纯| 老色鬼精品视频在线观看播放| 免费精品视频在线| 久久新电视剧免费观看| 欧美一二三四区在线| 色一情一伦一子一伦一区| 国产成人av影院| 91美女精品福利| 欧美三片在线视频观看| 中文字幕乱码久久午夜不卡| 国产婷婷色一区二区三区在线| 国产精品久久久久影视| 亚洲成人av资源| 国产精品一区二区久久不卡| 99国内精品久久| 欧美xxxxxxxx| 亚洲午夜一区二区| 菠萝蜜视频在线观看一区| 欧美日本视频在线| 亚洲欧美日韩一区二区| 国产真实乱偷精品视频免| 国产1区2区3区精品美女| 在线综合视频播放| 亚洲国产另类av| 972aa.com艺术欧美| 欧美国产精品中文字幕| 另类小说一区二区三区| 欧美高清视频不卡网| 一区二区日韩av| 欧美午夜片在线看| 亚洲三级在线观看| 99热精品一区二区| 久久久五月婷婷| 狠狠色丁香婷婷综合| 日韩视频国产视频| 欧美久久久久久蜜桃| 不卡电影一区二区三区| 亚洲精品在线三区| 日本成人在线一区| 欧美国产欧美综合| 99国产精品久久久久久久久久久| 中文字幕精品一区二区精品绿巨人| 九九热在线视频观看这里只有精品| 亚洲一区欧美一区| 欧美成人高清电影在线| 91精品国产免费| 国产女主播视频一区二区| 国产精品网友自拍| 国产精品传媒入口麻豆| 亚洲午夜久久久久久久久电影院| 精一区二区三区| 欧美高清视频www夜色资源网| 亚洲精品视频自拍| 国产蜜臀av在线一区二区三区| 亚洲午夜精品网| 欧美日韩中文一区| 一区二区三区在线看| youjizz久久| 在线观看亚洲一区| 欧美老年两性高潮| 国产精品每日更新在线播放网址| 亚洲第一二三四区| 一本色道a无线码一区v| 免费观看日韩av| 日韩欧美中文字幕一区| 2023国产精品自拍| 欧美亚洲另类激情小说| 色婷婷综合五月| 91精品国产欧美日韩| 亚洲一区av在线| 欧美亚洲国产一区二区三区| 国产一区二区调教| 国产午夜精品美女毛片视频| 欧美在线观看视频一区二区| 蜜臀久久99精品久久久久宅男| 视频一区在线视频| 欧美在线综合视频| 亚洲视频电影在线| 成a人片国产精品| 国产嫩草影院久久久久| 国产精品一区二区三区网站| 欧美成人猛片aaaaaaa| 免费在线看一区| 欧美一级电影网站| 免费精品99久久国产综合精品|