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

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

?? os_sem.c

?? LPC2104/5/6嵌入式系統程序實例,帶有PROTUES7.1仿真文件,適合做入門指導
?? 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一区二区三区免费野_久草精品视频
久久九九全国免费| 五月激情丁香一区二区三区| 久久久久久久综合日本| 国产亚洲一区二区三区四区| 亚洲国产一区视频| 国产99久久精品| 久久综合久久综合久久综合| 日本不卡一二三| 日本精品一级二级| 国产精品久久久久久亚洲伦| 国产精品美女久久久久久| 亚洲欧美另类综合偷拍| 亚洲一区二区精品视频| 欧美最新大片在线看| www.激情成人| 欧美国产成人在线| 国产69精品久久久久毛片| 精品国产在天天线2019| 久久国产福利国产秒拍| 这里只有精品99re| 亚洲欧美一区二区三区久本道91 | 欧美大胆一级视频| 亚洲五月六月丁香激情| 在线看国产一区二区| 亚洲精品一二三四区| 欧美亚洲国产一区二区三区va| 亚洲欧美一区二区久久| 色94色欧美sute亚洲线路一久| 亚洲精品国产精华液| 欧美日韩小视频| 亚洲成人午夜电影| 欧美一级一区二区| 韩国一区二区在线观看| 国产三级欧美三级日产三级99| 成人性视频免费网站| 国产精品三级视频| 欧美亚洲国产bt| 国产福利一区在线观看| 一区二区三区在线免费| 日韩网站在线看片你懂的| 处破女av一区二区| 亚洲18色成人| 1024成人网| 欧美精品高清视频| 97精品视频在线观看自产线路二| 午夜久久久久久久久久一区二区| 欧美一卡2卡3卡4卡| 在线视频欧美精品| 成人av在线播放网站| 免费在线一区观看| 一区二区三区久久| 久久精品水蜜桃av综合天堂| 欧美日韩电影在线播放| 色哟哟欧美精品| 国产成人aaaa| 久久99久久99小草精品免视看| 亚洲免费观看视频| 欧美国产97人人爽人人喊| 久久久亚洲精品一区二区三区| 9191成人精品久久| 欧美中文字幕亚洲一区二区va在线 | 国产精品自拍av| 美女性感视频久久| 精品亚洲免费视频| 日韩有码一区二区三区| 久久精品人人做人人综合| 精品欧美一区二区三区精品久久| 91久久精品国产91性色tv| 国产一区二区影院| 国产乱国产乱300精品| 国产一区二区在线免费观看| 精品亚洲porn| 秋霞av亚洲一区二区三| 午夜视黄欧洲亚洲| 日产欧产美韩系列久久99| 久久99国产精品免费网站| 激情文学综合插| 另类专区欧美蜜桃臀第一页| 蜜臀久久久久久久| 国产乱码精品一区二区三区忘忧草 | 国产欧美精品在线观看| 一区二区免费在线| 麻豆精品在线播放| 成人小视频在线| 粉嫩欧美一区二区三区高清影视| 国产精品资源网| 日韩三级精品电影久久久| 337p亚洲精品色噜噜噜| 国产欧美一区二区三区网站| 亚洲欧美综合在线精品| 欧美色图激情小说| 91久久一区二区| 欧美在线视频全部完| 欧美日本在线视频| 国产三级精品三级| 奇米影视一区二区三区| 日本视频一区二区三区| 亚洲va韩国va欧美va| 日韩国产精品大片| 天天色天天操综合| 日韩综合在线视频| 久久97超碰色| 国产精品美女久久福利网站| 亚洲大片在线观看| 成人免费福利片| 欧美男男青年gay1069videost| 日韩免费观看高清完整版| 国产精品无遮挡| 奇米精品一区二区三区在线观看| 国产精品99久久久久久久女警 | 久久综合九色综合欧美亚洲| 欧美韩国日本不卡| 国产一区二区免费在线| 日韩欧美电影在线| 午夜精品久久久久久不卡8050| 成人av网站在线观看免费| 欧美一二三四在线| 久久99精品国产.久久久久久| 欧美日韩亚洲综合一区| 亚洲伦在线观看| 91视频免费看| 一区二区三区在线免费观看| 91免费观看在线| 亚洲成人精品一区二区| 国产精品夜夜爽| aaa国产一区| 裸体在线国模精品偷拍| 亚洲欧美电影一区二区| 欧美一卡二卡三卡| 欧美日韩国产精品自在自线| 精品一区免费av| 麻豆精品一区二区三区| 亚洲综合在线视频| 久久影院视频免费| 制服丝袜日韩国产| 91麻豆精品国产综合久久久久久| 国产福利不卡视频| 久久蜜桃香蕉精品一区二区三区| 美女一区二区视频| 欧美激情在线免费观看| 欧美三级日韩三级国产三级| 青椒成人免费视频| 亚洲资源中文字幕| 久久精品亚洲乱码伦伦中文| 欧美日韩日本视频| 国产91高潮流白浆在线麻豆| 午夜私人影院久久久久| 欧美精品一区二区三区视频| 日韩精品欧美精品| 亚洲色图制服丝袜| 日韩欧美三级在线| 91麻豆精品国产91久久久久久久久| 国产91丝袜在线18| 麻豆免费看一区二区三区| 午夜影院在线观看欧美| 日韩一区二区三区视频在线 | 日韩一区二区三区四区五区六区| 波多野结衣中文字幕一区二区三区| 美女一区二区视频| 久久成人av少妇免费| 亚洲综合成人在线视频| 婷婷丁香久久五月婷婷| 亚洲国产精品久久人人爱 | 欧美自拍丝袜亚洲| 99精品视频中文字幕| 美女一区二区久久| 国产自产高清不卡| 国产99一区视频免费| 成人免费视频app| 欧美日韩欧美一区二区| 国产精品区一区二区三| 久久综合网色—综合色88| 色综合视频在线观看| 国产成人午夜99999| 欧美一级xxx| 国内精品不卡在线| 久久电影国产免费久久电影| 亚洲欧美日韩国产手机在线| 在线精品国精品国产尤物884a| 日本午夜一本久久久综合| 亚洲影视在线播放| 亚洲国产精品精华液网站| 久久久噜噜噜久噜久久综合| 久久伊99综合婷婷久久伊| 欧美日韩日日骚| 97se亚洲国产综合自在线观| 黑人巨大精品欧美黑白配亚洲| 免费日本视频一区| 麻豆精品国产传媒mv男同| 亚洲国产综合91精品麻豆| 亚洲免费在线播放| 日韩一区精品视频| 国产成人亚洲综合色影视| 777欧美精品| 欧美国产国产综合| 老汉av免费一区二区三区 | av色综合久久天堂av综合| 精品视频一区三区九区| 久久久久久久性| 日产国产欧美视频一区精品|