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

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

?? os_sem.c

?? uC_OSII移植源碼lumit_Ucosii_110.src.zip
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2001, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.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)
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;
#endif    
    INT16U     cnt;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
#endif
    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)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_EVENT  *pevent;


    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                      */
        OS_EventWaitListInit(pevent);
    }
    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)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    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);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    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) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 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    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久99| 亚洲va天堂va国产va久| 国产精品1区2区3区在线观看| 日韩欧美aaaaaa| 极品少妇xxxx精品少妇| 久久久91精品国产一区二区三区| 激情六月婷婷综合| 国产日韩欧美电影| 91亚洲精品久久久蜜桃网站| 亚洲国产一区在线观看| 欧美一区永久视频免费观看| 久久国产精品第一页| 国产日韩欧美精品一区| 91福利在线看| 久久99在线观看| 国产精品伦理在线| 欧美日韩成人激情| 极品少妇一区二区| 亚洲免费观看高清| 这里只有精品电影| 国产91高潮流白浆在线麻豆| 亚洲丝袜自拍清纯另类| 欧美精品在线观看一区二区| 久久国产乱子精品免费女| 国产免费久久精品| 欧美性色欧美a在线播放| 精品无人区卡一卡二卡三乱码免费卡 | 欧美日韩亚洲综合一区 | 男人的j进女人的j一区| 久久久精品免费网站| 色悠悠久久综合| 理论片日本一区| 中文字幕日本不卡| 日韩午夜精品电影| 一本一道久久a久久精品综合蜜臀| 三级在线观看一区二区| 中文一区在线播放| 欧美一区二区视频观看视频| 成人网在线免费视频| 亚洲妇女屁股眼交7| 国产日产欧美一区二区视频| 欧美三级三级三级| 成人做爰69片免费看网站| 亚洲国产精品欧美一二99| 日本一区二区视频在线| 69成人精品免费视频| 波多野结衣亚洲| 久久99精品久久久| 亚洲3atv精品一区二区三区| 日本一区二区高清| 欧美变态凌虐bdsm| 亚洲精品自拍动漫在线| 欧美成人激情免费网| 91成人看片片| 99久久精品久久久久久清纯| 国产毛片精品视频| 美女精品自拍一二三四| 亚洲高清久久久| 亚洲精品国产精华液| 中文字幕精品在线不卡| 欧美成人精品高清在线播放| 3atv一区二区三区| 欧美日本国产一区| 欧美日韩亚洲综合一区二区三区| 99精品欧美一区| 99精品偷自拍| 97久久精品人人做人人爽50路| 国产麻豆一精品一av一免费| 国产综合色视频| 久久av资源站| 国产一区二区三区免费在线观看| 日韩电影免费在线观看网站| 亚洲成人激情综合网| 亚洲国产aⅴ天堂久久| 亚洲成人av一区| 亚洲国产婷婷综合在线精品| 亚洲成人免费看| 午夜精品福利一区二区三区av| 亚洲一区在线观看免费| 午夜欧美2019年伦理| 亚洲一二三区不卡| 日韩精品电影在线观看| 蜜臀a∨国产成人精品| 久久成人18免费观看| 国产中文字幕一区| 高潮精品一区videoshd| 成人深夜在线观看| 91免费看`日韩一区二区| 97久久超碰国产精品电影| 色婷婷av一区二区三区软件| 在线精品视频小说1| 欧美剧情电影在线观看完整版免费励志电影 | 日韩一卡二卡三卡四卡| 欧美一区二区三级| 26uuu亚洲婷婷狠狠天堂| 2021中文字幕一区亚洲| 欧美韩日一区二区三区四区| 1区2区3区国产精品| 一区二区三区国产| 久久国产乱子精品免费女| 国产精品一区二区视频| 91视频在线看| 91精品国产综合久久香蕉麻豆| 精品久久久久久无| 国产精品天天看| 亚洲一区二区视频在线观看| 日本不卡1234视频| 成人丝袜视频网| 欧美日韩国产在线观看| 精品国内二区三区| 亚洲精品亚洲人成人网在线播放| 午夜精品福利一区二区三区蜜桃| 国产麻豆精品在线| 色视频成人在线观看免| 日韩西西人体444www| 欧美国产激情一区二区三区蜜月| 亚洲美女精品一区| 久久99热国产| 色8久久人人97超碰香蕉987| 日本一道高清亚洲日美韩| 国产精品影视在线| 欧美在线免费观看亚洲| 精品久久人人做人人爰| 一卡二卡三卡日韩欧美| 激情文学综合网| 色成年激情久久综合| 久久久久亚洲综合| 亚洲1区2区3区视频| www.av亚洲| 欧美va在线播放| 伊人性伊人情综合网| 国产在线国偷精品免费看| 欧美在线高清视频| 亚洲国产高清不卡| 久久99国产精品久久99果冻传媒| 91免费视频观看| 中文字幕的久久| 久久国产精品无码网站| 欧美日韩高清影院| 亚洲欧美综合网| 成人性视频网站| 亚洲精品一区二区三区精华液| 亚洲午夜电影在线观看| 91香蕉视频污| 国产精品成人免费在线| 国产麻豆成人精品| 精品久久久久久久一区二区蜜臀| 亚洲3atv精品一区二区三区| 色八戒一区二区三区| 亚洲欧洲av另类| 成人av小说网| 国产精品视频第一区| 国产一区二区在线免费观看| 欧美v日韩v国产v| 麻豆精品视频在线| 777奇米成人网| 日韩高清电影一区| 欧美日韩第一区日日骚| 亚洲国产精品久久久男人的天堂| 色婷婷国产精品综合在线观看| 国产精品国产三级国产有无不卡| 国产九色精品成人porny| 精品日本一线二线三线不卡| 老司机精品视频在线| 欧美一区二区精美| 天涯成人国产亚洲精品一区av| 欧美视频精品在线| 亚洲一级片在线观看| 欧美日本精品一区二区三区| 丝袜诱惑亚洲看片| 欧美日韩情趣电影| 亚洲成av人片在线| 91精品国产欧美一区二区成人| 视频一区二区不卡| 日韩欧美在线影院| 激情文学综合丁香| 国产日韩欧美a| 99re成人在线| 亚洲成人自拍偷拍| 7777精品伊人久久久大香线蕉| 麻豆视频一区二区| 亚洲精品在线观看网站| 国产精品主播直播| 中文字幕在线一区二区三区| 成人app网站| 亚洲国产视频网站| 日韩欧美一二三四区| 国产成人欧美日韩在线电影| 中文字幕中文字幕一区二区| 色综合久久久久综合体桃花网| 亚洲国产裸拍裸体视频在线观看乱了 | 婷婷开心激情综合| 日韩无一区二区| 岛国精品一区二区| 一区二区三区四区av| 日韩欧美你懂的| 91影视在线播放| 久久国产精品99精品国产| 国产精品成人一区二区艾草| 欧美亚洲综合网|