亚洲欧美第一页_禁久久精品乱码_粉嫩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久久精品欧美| 蜜臀av国产精品久久久久| 亚洲精品日日夜夜| 91在线观看成人| 中文一区二区完整视频在线观看| 国模无码大尺度一区二区三区| 欧美吻胸吃奶大尺度电影| 一区二区三区精品视频在线| 成人av网址在线观看| 亚洲国产精品v| 色呦呦一区二区三区| 一区二区三区四区亚洲| 欧美影院一区二区三区| 亚洲国产精品成人综合| 91香蕉视频污在线| 亚洲第一电影网| 精品欧美乱码久久久久久| 黄一区二区三区| 国产精品久久久久aaaa| 91免费在线视频观看| 亚洲不卡在线观看| 精品粉嫩aⅴ一区二区三区四区| 国产精品中文字幕欧美| 亚洲精品免费看| 91精品婷婷国产综合久久性色| 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美性感一区二区三区| 天天亚洲美女在线视频| 久久久蜜臀国产一区二区| 成人综合婷婷国产精品久久蜜臀 | 免费av成人在线| 国产精品色在线| 欧美另类一区二区三区| 国产一区二区福利| 亚洲成a人片综合在线| 国产日本亚洲高清| 日韩欧美成人一区二区| 成人深夜视频在线观看| 日韩福利视频网| 1000部国产精品成人观看| 国产精品视频一二三区 | 亚洲精品一区二区三区福利| 国内精品国产成人国产三级粉色| 国产精品久久久99| 26uuu另类欧美亚洲曰本| 欧美精品vⅰdeose4hd| 99精品视频一区二区三区| 国产精品99久久久久久宅男| 婷婷成人综合网| 午夜久久久久久久久久一区二区| 中文字幕二三区不卡| 国产亚洲精品aa午夜观看| 久久综合九色欧美综合狠狠| 欧美精品免费视频| 91精品国产综合久久蜜臀| 欧美日韩高清一区二区三区| 欧美电影免费观看高清完整版| 成人免费视频国产在线观看| 日日摸夜夜添夜夜添亚洲女人| 日韩女优制服丝袜电影| 欧美日韩另类一区| 在线欧美日韩精品| 欧美高清dvd| 2020日本不卡一区二区视频| 中文字幕免费不卡| 日韩在线a电影| 国产精品一品视频| av高清不卡在线| 欧洲另类一二三四区| 欧美日本在线观看| 国产日韩欧美在线一区| 一区二区三区在线免费观看| 免费高清在线视频一区·| 福利一区二区在线观看| 欧美日韩免费观看一区三区| 欧美最猛黑人xxxxx猛交| 欧美视频一区二区在线观看| 日韩欧美激情四射| 亚洲一区免费视频| 激情深爱一区二区| 7777女厕盗摄久久久| 自拍偷拍国产亚洲| 国产91在线看| 精品剧情v国产在线观看在线| 最新不卡av在线| 国产精品99久久久久久宅男| 欧美影院一区二区| 亚洲欧洲www| 成人免费不卡视频| 国产精品少妇自拍| 成人免费观看男女羞羞视频| 欧美绝品在线观看成人午夜影视| 久久人人爽爽爽人久久久| 免费观看日韩电影| 欧美美女视频在线观看| 亚洲免费色视频| 欧美色图在线观看| 午夜精品在线看| 欧美巨大另类极品videosbest | 日韩女同互慰一区二区| 日本不卡免费在线视频| 久久在线观看免费| 国产美女av一区二区三区| 欧美大片一区二区| 毛片基地黄久久久久久天堂| 日韩一区二区在线免费观看| 老司机午夜精品| 久久久午夜精品理论片中文字幕| 国产精品99久久久久久似苏梦涵| 久久影院视频免费| av电影一区二区| 一区二区久久久| 91麻豆精品国产91久久久久久久久| 亚洲综合在线第一页| 欧美精品三级日韩久久| 韩国精品久久久| 久久久精品免费免费| 国产大陆亚洲精品国产| 亚洲欧美激情视频在线观看一区二区三区| 色综合色综合色综合色综合色综合| 天天av天天翘天天综合网| 久久婷婷一区二区三区| 99久久亚洲一区二区三区青草| 一区二区三区不卡在线观看 | 欧美成人官网二区| 色综合天天综合狠狠| 亚洲天堂成人在线观看| 欧美日韩综合在线| 国产成人在线色| 奇米888四色在线精品| 国产精品福利一区二区三区| 91精品国产综合久久福利软件| 91亚洲永久精品| 国产精品69久久久久水密桃| 一区二区成人在线视频| 久久五月婷婷丁香社区| 日韩午夜在线播放| 欧美综合在线视频| 色婷婷久久综合| 欧美中文字幕一二三区视频| 91亚洲精华国产精华精华液| 久久国产精品色婷婷| 琪琪久久久久日韩精品| 一区二区高清在线| 亚洲美女少妇撒尿| 国产精品毛片久久久久久久| 中文字幕在线不卡一区二区三区| 精品理论电影在线| 久久新电视剧免费观看| 5566中文字幕一区二区电影| 欧美色爱综合网| 欧美日韩精品福利| 精品久久久久久最新网址| 国产亚洲一区二区三区在线观看 | 欧美三级视频在线| 欧美情侣在线播放| 精品久久一二三区| 国产精品国产三级国产aⅴ中文| 国产精品毛片大码女人| 亚洲激情av在线| 午夜电影网一区| 激情五月激情综合网| 日本黄色一区二区| 日韩一区二区三区在线观看 | 成人精品电影在线观看| aaa国产一区| 欧美日韩精品一区二区三区| 精品对白一区国产伦| 一区二区视频免费在线观看| 免费的成人av| jlzzjlzz国产精品久久| 欧美美女直播网站| 久久精品人人做人人综合| 亚洲一卡二卡三卡四卡无卡久久| 国产中文一区二区三区| 69堂精品视频| 亚洲图片一区二区| 国产成人免费视| 欧美第一区第二区| 亚洲一区日韩精品中文字幕| 成人av电影在线网| 欧美精品一区二区三区在线播放| 中文字幕一区在线观看视频| 偷拍一区二区三区| 色婷婷久久久久swag精品| 中文字幕免费观看一区| 国产91在线|亚洲| 中文字幕av一区二区三区| 免费在线观看视频一区| 欧美视频在线不卡| 亚洲无线码一区二区三区| 91亚洲精华国产精华精华液| 国产精品丝袜一区| 成人av在线影院| 国产精品美女一区二区三区|