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

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

?? os_sem.c

?? C語言源代碼及相關資料
?? 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一区二区三区免费野_久草精品视频
免费久久精品视频| 亚洲影视在线播放| 国产精品88888| 久久久久久久久久看片| 国产传媒日韩欧美成人| 成人免费在线播放视频| caoporm超碰国产精品| 亚洲蜜臀av乱码久久精品 | 亚洲色图欧美偷拍| 99国产精品视频免费观看| 亚洲美女在线国产| 欧美日韩国产另类一区| 九九久久精品视频| 国产精品国产精品国产专区不片 | 一区二区三区中文字幕精品精品 | 亚洲猫色日本管| 欧美撒尿777hd撒尿| 首页国产丝袜综合| www亚洲一区| 91女厕偷拍女厕偷拍高清| 亚洲午夜电影在线观看| 91麻豆精品国产自产在线观看一区 | 欧美日韩精品免费| 激情综合色综合久久| 国产精品乱码久久久久久| 一本色道久久综合狠狠躁的推荐| 天堂成人国产精品一区| 亚洲精品一区二区三区香蕉| 97se亚洲国产综合自在线 | 欧美高清在线精品一区| 欧美日韩一级黄| 国产高清亚洲一区| 亚洲一区二区三区四区的| 久久天天做天天爱综合色| 色综合天天做天天爱| 免费在线观看视频一区| 亚洲男帅同性gay1069| 精品国产乱码久久| 欧美主播一区二区三区| 国产激情91久久精品导航| 午夜激情久久久| 国产精品国产三级国产aⅴ入口 | 国产成人av电影免费在线观看| 一区二区三区在线免费播放| 久久婷婷国产综合精品青草 | 麻豆国产精品777777在线| 中文字幕在线播放不卡一区| 欧美电视剧在线看免费| 在线亚洲一区二区| 国产91精品一区二区麻豆亚洲| 日韩在线一区二区三区| 亚洲精品成人精品456| 久久久九九九九| 91精品国产综合久久国产大片| 91丝袜美女网| 东方aⅴ免费观看久久av| 日韩成人午夜精品| 一区二区三区视频在线看| 国产欧美一区二区三区在线看蜜臀| 51精品久久久久久久蜜臀| 97久久精品人人做人人爽| 国产成人在线视频播放| 精品一区二区三区在线视频| 午夜精品aaa| 亚洲第一电影网| 亚洲最大成人网4388xx| 中文字幕在线不卡| 国产精品国产成人国产三级 | 日本成人在线电影网| 亚洲h动漫在线| 一区二区三区91| 亚洲免费在线观看| 一区二区三区在线观看动漫| 中文字幕在线免费不卡| 中文字幕精品三区| 国产欧美一区视频| 国产精品美女久久久久高潮| 欧美国产日韩在线观看| 中文字幕的久久| 国产清纯白嫩初高生在线观看91| 国产香蕉久久精品综合网| 久久久91精品国产一区二区精品| 26uuu欧美| 久久一留热品黄| 国产日产欧产精品推荐色| 国产精品无人区| 最新国产の精品合集bt伙计| 亚洲视频电影在线| 一区二区三区四区不卡在线 | 成人av在线播放网址| 成人午夜免费电影| 97精品视频在线观看自产线路二| 91丨porny丨在线| 在线免费观看日本欧美| 欧美精三区欧美精三区| 精品久久一二三区| 国产欧美日本一区视频| 亚洲欧美另类在线| 亚洲成国产人片在线观看| 麻豆精品视频在线观看| 国产精品18久久久久久久网站| 播五月开心婷婷综合| 色激情天天射综合网| 欧美三级资源在线| 亚洲精品一区二区三区影院| 国产精品青草综合久久久久99| 亚洲欧美偷拍另类a∨色屁股| 亚洲影视资源网| 激情国产一区二区 | 精品一区二区三区在线视频| 成人黄色在线视频| 精品视频在线免费观看| 精品日产卡一卡二卡麻豆| 国产精品久久午夜夜伦鲁鲁| 亚洲精品欧美综合四区| 蜜臀av一区二区在线免费观看| 国产精品1区2区3区| 欧美图片一区二区三区| 久久久五月婷婷| 亚洲一区二区美女| 国产成人亚洲精品狼色在线 | 久久国产夜色精品鲁鲁99| 成人av在线一区二区| 91精品国产91综合久久蜜臀| 国产欧美在线观看一区| 丝袜美腿高跟呻吟高潮一区| 成人教育av在线| 欧美一区二区三区四区五区 | 成人国产精品免费观看| 91精品国产免费久久综合| 中文字幕一区二区三区精华液| 日韩高清中文字幕一区| 99国产精品久| 91在线观看一区二区| 久久众筹精品私拍模特| 亚洲成人www| 91麻豆国产自产在线观看| 欧美本精品男人aⅴ天堂| 亚洲图片有声小说| 9i在线看片成人免费| 精品蜜桃在线看| 视频一区视频二区在线观看| 99久久精品免费看国产 | 久久精品一区二区三区不卡牛牛| 亚洲在线视频网站| 99精品视频在线免费观看| 26uuuu精品一区二区| 琪琪久久久久日韩精品| 欧美午夜精品一区二区三区| 中文字幕在线不卡视频| 国产白丝精品91爽爽久久| 日韩欧美成人激情| 日韩电影在线一区二区| 欧美日韩一区二区三区四区五区| 国产精品美女久久久久久2018| 国产一区二区调教| 日韩三级精品电影久久久| 亚洲成av人片在线观看| 在线精品视频免费播放| 亚洲精品视频在线观看免费| 99国产一区二区三精品乱码| 中文字幕一区二区三区在线观看 | 蜜桃免费网站一区二区三区| 欧美男生操女生| 午夜精品123| 91精品视频网| 水蜜桃久久夜色精品一区的特点 | 精品一区二区综合| 日韩丝袜情趣美女图片| 美女网站一区二区| 精品福利一区二区三区免费视频| 美女视频一区二区| 久久综合久久鬼色| 国产福利一区二区三区视频在线| 久久久国产精品午夜一区ai换脸| 激情综合一区二区三区| 国产婷婷色一区二区三区| 国产精品一区久久久久| 国产精品色在线| 99re视频精品| 婷婷国产v国产偷v亚洲高清| 欧美一区二区在线观看| 久久99精品国产.久久久久久| 精品日韩一区二区三区 | 亚洲男人的天堂在线aⅴ视频| 99精品视频免费在线观看| 亚洲乱码国产乱码精品精98午夜| 91美女精品福利| 亚洲一区二区不卡免费| 在线不卡a资源高清| 麻豆高清免费国产一区| 国产精品丝袜91| 91久久精品一区二区三| 日韩综合一区二区| 久久综合九色欧美综合狠狠| 岛国精品在线观看| 久久精品国产秦先生| 中文字幕不卡在线观看| 欧美三级电影在线看| 国产毛片精品国产一区二区三区|