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

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

?? os_sem.c

?? 我現在需要看幾個論文。。今年馬上畢業。。急著用
?? 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精品国产综合久久久久| 国产乱人伦偷精品视频不卡| 91丨porny丨国产| 亚洲欧美激情视频在线观看一区二区三区 | 午夜av一区二区| 3atv在线一区二区三区| 九九九久久久精品| 国产精品欧美一级免费| 91激情五月电影| 亚洲1区2区3区视频| 久久综合九色综合久久久精品综合 | 石原莉奈一区二区三区在线观看| 日韩一区二区高清| 国产91精品在线观看| 亚洲精品第一国产综合野| 欧美高清视频不卡网| 国产一区二区三区四区在线观看| 国产精品久久久久久久久免费丝袜| 在线免费不卡电影| 久久国产精品免费| 国产精品大尺度| 91麻豆精品国产91| 成人av综合一区| 亚洲电影视频在线| 国产欧美日韩视频一区二区| 色94色欧美sute亚洲线路一久 | 波多野结衣中文一区| 国产福利91精品| 91香蕉视频污| 久久综合九色综合久久久精品综合| 精品一区二区三区av| 日韩精品一区二区三区在线观看| 亚洲综合在线视频| 欧美美女bb生活片| 日韩高清国产一区在线| av资源网一区| 国产精品丝袜久久久久久app| 国产乱对白刺激视频不卡| 久久综合色天天久久综合图片| 激情久久五月天| 国产精品乱子久久久久| 欧美一级理论性理论a| 国产精品888| 午夜欧美大尺度福利影院在线看| 欧美色中文字幕| 国产精品1区2区| 亚洲国产精品影院| 久久久久久久综合日本| 91在线观看成人| 国产精品亚洲视频| 亚州成人在线电影| 亚洲影视在线观看| 亚洲人成网站色在线观看| 精品国产第一区二区三区观看体验| 成人禁用看黄a在线| 久久精品国产999大香线蕉| 亚洲精品免费在线观看| 欧美精彩视频一区二区三区| 日韩一二三区视频| 欧美一区二区黄色| 91精品国产综合久久精品app| 97超碰欧美中文字幕| 在线看日韩精品电影| 欧美色大人视频| 欧美亚洲一区三区| 欧美日韩精品高清| 日韩美女天天操| 国产欧美综合色| 亚洲精品日韩综合观看成人91| 国产精品欧美一区喷水| 亚洲视频在线一区| 亚洲第一二三四区| 日韩在线一二三区| 美女性感视频久久| 国产成人精品亚洲午夜麻豆| 色综合天天综合| 欧美色老头old∨ideo| 精品欧美一区二区在线观看| 中文字幕不卡一区| 日韩精品福利网| 成人高清av在线| 91精品婷婷国产综合久久性色| 日韩欧美国产午夜精品| 亚洲精品午夜久久久| 国产一区 二区| 欧美久久久久久久久久| 欧美国产日韩a欧美在线观看| 日韩精品亚洲一区| 99re这里只有精品首页| 久久综合久久99| 图片区小说区区亚洲影院| 国产成人自拍网| 欧美电视剧免费全集观看| 亚洲综合一区在线| 91老司机福利 在线| 中文字幕一区二区三区四区| 国产综合久久久久久鬼色 | 精品一区二区三区影院在线午夜| 在线观看区一区二| 亚洲国产精品久久不卡毛片 | 国产酒店精品激情| 欧美一区二区在线观看| 日韩在线a电影| 日韩欧美亚洲一区二区| 国产精品一区二区不卡| 久久亚区不卡日本| 不卡的av电影| 日本欧美一区二区三区乱码| 91精品国产免费久久综合| 日韩和欧美一区二区| 精品少妇一区二区三区免费观看| 日本欧美加勒比视频| 久久欧美中文字幕| 欧美午夜在线一二页| 看电视剧不卡顿的网站| 中文字幕不卡在线播放| 91麻豆精品国产91久久久久| 国内精品免费**视频| 国产精品久久久久久久久快鸭 | 国产视频一区在线观看| 欧美性猛交一区二区三区精品| 久久国产精品99精品国产| 国产精品理论片| 久久精品夜夜夜夜久久| 678五月天丁香亚洲综合网| 国产成人av资源| 奇米影视一区二区三区小说| 国产精品久线在线观看| 欧美成人三级电影在线| 欧美三级电影精品| 一本大道av伊人久久综合| 国产伦精品一区二区三区视频青涩| 亚洲免费看黄网站| 亚洲欧洲色图综合| 中文字幕在线播放不卡一区| 精品动漫一区二区三区在线观看| 精品视频在线免费| 91久久精品一区二区三区| 99久久精品国产一区二区三区| 狠狠色丁香久久婷婷综合_中| 日韩成人伦理电影在线观看| 午夜伦理一区二区| 蜜桃精品视频在线观看| 久久精品99国产国产精| 精品中文av资源站在线观看| 经典三级在线一区| 成人av网站在线| 欧美午夜精品一区二区蜜桃| 欧美日韩一区不卡| 精品欧美乱码久久久久久| 久久精品视频免费观看| 一区二区中文视频| 天天色综合成人网| 国产精品一区二区三区乱码| 日本丶国产丶欧美色综合| 91精品黄色片免费大全| 26uuu久久天堂性欧美| 中文字幕永久在线不卡| 日本不卡的三区四区五区| 国产成人午夜99999| 欧美图片一区二区三区| 日韩欧美123| 亚洲小少妇裸体bbw| 成人午夜又粗又硬又大| 91精品婷婷国产综合久久| 国产精品久久福利| 免播放器亚洲一区| 欧美精品久久一区| 亚洲激情图片qvod| 成人av网站在线观看免费| 26uuu精品一区二区| 麻豆成人免费电影| 日韩一区二区三区电影| 午夜天堂影视香蕉久久| 91香蕉视频污在线| 中文av一区特黄| 成人免费精品视频| 国产日韩欧美综合一区| 国产乱人伦精品一区二区在线观看| 欧美蜜桃一区二区三区| 一个色综合av| 欧美日高清视频| 蜜桃在线一区二区三区| 日韩精品中文字幕一区 | 欧美一区二区三区在线观看视频 | 2021国产精品久久精品| 国产高清精品在线| 国产精品国产三级国产普通话蜜臀 | 一区二区三区四区视频精品免费| 99国产精品久久久久久久久久| 亚洲婷婷综合色高清在线| 99久久99久久免费精品蜜臀| 亚洲国产一区二区视频| 欧美日韩不卡视频| 亚洲电影一级片| 久久这里都是精品| 91在线精品一区二区| 免费一级片91| 亚洲午夜精品一区二区三区他趣| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 |