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

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

?? os_sem.c

?? 嵌入式操作系統 arm-ucos2041
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2002, 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                      */
        pevent->OSEventPtr  = (void *)0;                   /* Unlink from ECB free list                */
        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)
{
#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一区二区三区免费野_久草精品视频
成人精品亚洲人成在线| 亚洲第一狼人社区| 国产精品另类一区| 亚洲综合成人在线视频| 国产精品中文欧美| 7777女厕盗摄久久久| 国产精品久久久久久久第一福利 | 欧美成人伊人久久综合网| ...xxx性欧美| 亚洲在线一区二区三区| 国产黄人亚洲片| 欧美日本一区二区三区四区| 欧美国产日韩亚洲一区| 男男成人高潮片免费网站| 91精品国产综合久久小美女| 国产精品久久久久永久免费观看| 日本大胆欧美人术艺术动态| 97se狠狠狠综合亚洲狠狠| 精品国精品国产| 日韩av高清在线观看| 欧美日本乱大交xxxxx| 国产精品成人免费在线| 国产精品一区二区不卡| 精品国产乱码久久久久久免费| 亚洲成人第一页| av午夜一区麻豆| 国产精品情趣视频| 国内精品在线播放| 欧美精品色综合| 亚洲综合视频在线| 91亚洲精品久久久蜜桃| 国产视频911| 国产成人av资源| 精品精品欲导航| 五月婷婷欧美视频| 欧美精品色综合| 亚洲电影中文字幕在线观看| 99re视频精品| 亚洲色图欧洲色图| eeuss鲁片一区二区三区在线观看| 精品久久久久一区二区国产| 国内精品嫩模私拍在线| 日韩女优av电影在线观看| 婷婷综合另类小说色区| 337p亚洲精品色噜噜噜| 午夜电影网一区| 欧美日韩在线播放| 亚洲高清不卡在线| 欧美丝袜自拍制服另类| 亚洲国产精品久久不卡毛片 | 亚洲成人福利片| 欧美日韩精品一区二区天天拍小说| 亚洲美女淫视频| 日本道免费精品一区二区三区| 国产欧美1区2区3区| 99久久精品免费| 亚洲欧美日韩一区二区三区在线观看| 成人性生交大合| 国产精品入口麻豆九色| 成人av网站在线| 亚洲欧洲另类国产综合| 不卡在线视频中文字幕| 亚洲欧美日韩系列| 97久久超碰国产精品| 中文字幕的久久| 99久久99久久综合| 亚洲综合清纯丝袜自拍| 欧美在线高清视频| 亚洲电影在线播放| 欧美久久久久久久久久| 亚洲综合免费观看高清完整版在线| 在线精品视频免费观看| 亚洲一区视频在线| 欧美日韩成人一区二区| 日本色综合中文字幕| 制服丝袜一区二区三区| 精品亚洲成a人在线观看| 久久久www成人免费毛片麻豆| 国产精品18久久久久久久久| 国产精品久久久久久久久图文区| 91一区一区三区| 亚洲福利一区二区三区| 欧美一级欧美三级在线观看| 久久99久久久欧美国产| 欧美激情在线一区二区| zzijzzij亚洲日本少妇熟睡| 亚洲精品乱码久久久久久黑人 | 综合欧美亚洲日本| 在线视频欧美区| 美国毛片一区二区三区| 久久新电视剧免费观看| av中文字幕不卡| 午夜视频在线观看一区二区| 精品三级av在线| 成人国产一区二区三区精品| 亚洲综合网站在线观看| 日韩片之四级片| av电影一区二区| 丝袜美腿一区二区三区| 久久青草欧美一区二区三区| 91蜜桃婷婷狠狠久久综合9色| 一区二区三区日韩欧美精品| 日韩三区在线观看| 东方欧美亚洲色图在线| 亚洲高清三级视频| 久久久精品国产免大香伊| 一本一道久久a久久精品综合蜜臀| 日韩福利电影在线| 国产精品久久久久一区| 欧美日韩一级二级三级| 国产ts人妖一区二区| 最好看的中文字幕久久| 人人狠狠综合久久亚洲| 91精品国产高清一区二区三区| 国产不卡免费视频| 日韩精品一级中文字幕精品视频免费观看 | 日本精品免费观看高清观看| 国产一区二区在线观看视频| 亚洲一区中文日韩| 椎名由奈av一区二区三区| 精品久久久久久亚洲综合网 | thepron国产精品| 久久99国产精品免费网站| 依依成人综合视频| 国产精品国产三级国产三级人妇 | 一区二区三区日韩| 国产精品久久综合| 久久久久久影视| 精品久久久久久久人人人人传媒| 欧美日韩一区久久| 日本韩国欧美一区| av网站免费线看精品| 粉嫩蜜臀av国产精品网站| 国模娜娜一区二区三区| 久久国产欧美日韩精品| 蜜臀av一区二区三区| 日韩精品亚洲专区| 亚洲成a人v欧美综合天堂下载| 亚洲免费毛片网站| 亚洲欧美一区二区三区极速播放| 欧美国产国产综合| 国产亚洲欧美色| 国产午夜精品一区二区三区视频| 欧美大黄免费观看| 日韩欧美美女一区二区三区| 日韩天堂在线观看| 欧美一级免费大片| 日韩欧美中文字幕一区| 欧美r级电影在线观看| 日韩欧美成人激情| 精品少妇一区二区| 欧美精品一区二区三区蜜臀| 久久综合九色综合欧美亚洲| 日韩精品中文字幕一区二区三区| 欧美一区二区三区喷汁尤物| 欧美一区二区三区在线看 | 91丨九色丨蝌蚪富婆spa| 97久久久精品综合88久久| 成人sese在线| 91网站最新地址| 一本大道久久a久久综合| 在线亚洲欧美专区二区| 欧美午夜不卡视频| 欧美日韩高清一区| 日韩小视频在线观看专区| 欧美一区二区在线观看| 日韩欧美国产午夜精品| 精品成人一区二区| 久久精品免费在线观看| 国产精品系列在线| 亚洲精品视频观看| 亚洲动漫第一页| 美腿丝袜亚洲综合| 国产不卡视频一区| 色综合视频一区二区三区高清| 欧洲一区二区三区在线| 欧美一区二区精美| 久久久精品日韩欧美| 亚洲色欲色欲www| 香蕉乱码成人久久天堂爱免费| 青青草伊人久久| 国产999精品久久久久久绿帽| va亚洲va日韩不卡在线观看| 欧美午夜影院一区| 日韩免费电影网站| 中文字幕高清不卡| 亚洲韩国精品一区| 精品一区二区免费在线观看| 丰满少妇久久久久久久| 色婷婷综合在线| 91精品国产欧美一区二区| 国产亚洲污的网站| 一区二区三区精品| 久久9热精品视频| 成人黄色一级视频| 3d动漫精品啪啪一区二区竹菊| 久久久亚洲精品石原莉奈| 亚洲视频在线观看一区| 免费视频一区二区| 成人av网址在线观看|