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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? C語言源代碼及相關(guān)資料
?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品免费在线| 日韩午夜精品视频| 国产精品全国免费观看高清| 韩国欧美一区二区| 日韩久久久精品| 激情久久五月天| 久久免费国产精品| 国产麻豆日韩欧美久久| 久久精品在线免费观看| 成人一区在线看| 一色桃子久久精品亚洲| 国产亚洲综合性久久久影院| 国内不卡的二区三区中文字幕| 欧美大尺度电影在线| 激情深爱一区二区| 国产精品日产欧美久久久久| 91视频国产资源| 亚洲韩国一区二区三区| 91精品国产91久久综合桃花| 麻豆91精品视频| 久久精品人人做人人综合| 高清日韩电视剧大全免费| 日韩毛片在线免费观看| 欧美性色综合网| 精品一区二区三区久久久| 亚洲国产电影在线观看| 在线视频一区二区三| 欧美a级一区二区| 国产精品素人视频| 欧美日韩精品二区第二页| 捆绑紧缚一区二区三区视频| 国产欧美精品日韩区二区麻豆天美| 91一区在线观看| 奇米影视在线99精品| 欧美激情一区二区三区不卡| 在线看不卡av| 狠狠狠色丁香婷婷综合久久五月| 国产精品卡一卡二| 欧美一区二区三区色| 成人三级伦理片| 视频一区免费在线观看| 久久久久久久久97黄色工厂| 欧美午夜理伦三级在线观看| 国产精品影视网| 亚洲不卡一区二区三区| 国产欧美视频一区二区三区| 欧美丰满少妇xxxxx高潮对白| 国产一区二区精品久久99| 一区二区三区四区激情| 国产亚洲成aⅴ人片在线观看| 色诱视频网站一区| 久久精品国产网站| 亚洲综合999| 国产欧美精品区一区二区三区| 欧美午夜精品免费| 成人sese在线| 狠狠网亚洲精品| 午夜视频久久久久久| 亚洲欧洲www| 久久亚洲一级片| 欧美三级电影网| 99在线精品视频| 国产成人亚洲精品狼色在线 | 成人永久免费视频| 蜜臀久久久99精品久久久久久| 一区二区在线看| 中文字幕中文乱码欧美一区二区| 日韩精品一区二区三区老鸭窝 | 日韩午夜在线播放| 欧美日韩一区小说| 色久综合一二码| 99re亚洲国产精品| 成人晚上爱看视频| 国产91富婆露脸刺激对白| 精品一区二区三区久久| 免费在线观看精品| 日本视频免费一区| 视频一区在线播放| 日本欧美在线看| 日韩精品视频网站| 日韩激情在线观看| 日本伊人精品一区二区三区观看方式| 亚洲视频一区在线观看| 日韩美女精品在线| 亚洲乱码国产乱码精品精的特点| 国产精品乱人伦| 亚洲欧洲国产专区| 亚洲精品国产精华液| 一区二区三区av电影| 亚洲乱码中文字幕| 一区二区在线观看av| 亚洲影院在线观看| 无码av免费一区二区三区试看| 亚洲永久免费视频| 日本伊人色综合网| 久久电影国产免费久久电影 | 91精品国产综合久久福利软件| 欧美日韩在线三区| 91精品国产一区二区| 精品免费日韩av| 久久一日本道色综合| 国产日韩欧美综合在线| 国产精品电影院| 一区二区三区欧美亚洲| 婷婷六月综合亚洲| 麻豆国产精品一区二区三区| 国产精品一二三区在线| 国产91清纯白嫩初高中在线观看| 成人91在线观看| 91久久精品一区二区二区| 欧美视频中文一区二区三区在线观看 | 蜜臀久久99精品久久久画质超高清| 免费的成人av| 成人午夜在线免费| 日本高清不卡一区| 日韩精品一区二区三区中文不卡 | 亚洲午夜精品久久久久久久久| 丝袜美腿成人在线| 国产一区福利在线| av电影在线观看不卡| 欧美日韩不卡视频| 久久久久99精品国产片| 一区二区三区免费| 久久精工是国产品牌吗| 99精品欧美一区二区三区小说| 欧美三电影在线| 久久久久久久久久久久久夜| 伊人开心综合网| 狠狠色丁香婷婷综合| 欧美亚洲动漫精品| 国产午夜精品一区二区三区四区| 一区二区三区毛片| 国产一区二区不卡老阿姨| 色偷偷久久人人79超碰人人澡 | 26uuu色噜噜精品一区二区| 亚洲日本欧美天堂| 卡一卡二国产精品| 色偷偷久久人人79超碰人人澡 | 久久国产精品色婷婷| 一本久久a久久免费精品不卡| 欧美大肚乱孕交hd孕妇| 一区二区在线看| 国产精品1024| 欧美日韩国产高清一区二区| 久久久五月婷婷| 首页亚洲欧美制服丝腿| 不卡av在线网| 2023国产精品视频| 日本在线不卡一区| 欧美私模裸体表演在线观看| 国产精品家庭影院| 国产精品一二二区| 日韩你懂的在线观看| 亚洲国产精品麻豆| 91视频免费播放| 亚洲欧洲日韩综合一区二区| 国产伦精品一区二区三区视频青涩 | 午夜久久久久久久久久一区二区| 波多野洁衣一区| 国产亚洲自拍一区| 韩国女主播一区二区三区| 欧美精品tushy高清| 欧美不卡在线视频| 亚洲人吸女人奶水| 成人性视频网站| 日韩欧美成人午夜| 五月激情六月综合| 91小视频在线| 久久亚洲私人国产精品va媚药| 亚洲va天堂va国产va久| 久久久久99精品国产片| 婷婷综合久久一区二区三区| 99精品视频一区二区三区| 久久久精品日韩欧美| 国产一区亚洲一区| 日韩亚洲国产中文字幕欧美| 亚洲综合免费观看高清完整版 | 欧美一区二区在线免费播放| 亚洲色图在线看| 成人综合激情网| |精品福利一区二区三区| 国产专区综合网| 欧美成人精品1314www| 水蜜桃久久夜色精品一区的特点| 91精品一区二区三区在线观看| 一区二区三区免费观看| 色视频一区二区| 亚洲欧美日韩国产综合在线| 欧美色中文字幕| 一区二区免费看| 91久久免费观看| 亚洲人精品一区| 色综合久久九月婷婷色综合| 国产精品成人网| 99久久精品免费| 亚洲成人自拍偷拍| 欧美欧美午夜aⅴ在线观看| 天堂av在线一区| 欧美精品一区二区三区在线 | 蜜桃av一区二区三区电影|