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

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

?? os_sem.c

?? 周立功LPC2200系列ARM課件。課件內容含有動畫、內容詳細具體
?? 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一区二区三区免费野_久草精品视频
久久精品日产第一区二区三区高清版| 亚洲品质自拍视频网站| 自拍偷拍亚洲激情| 奇米888四色在线精品| 成人午夜大片免费观看| 日韩欧美一级特黄在线播放| 亚洲欧美区自拍先锋| 国产一区欧美一区| 777久久久精品| 亚洲综合av网| 97se狠狠狠综合亚洲狠狠| 久久蜜臀中文字幕| 久草在线在线精品观看| 欧美日本一区二区三区四区| 亚洲女同女同女同女同女同69| 国产精品 日产精品 欧美精品| 欧美一级夜夜爽| 亚洲国产精品久久久久秋霞影院| 粉嫩av一区二区三区粉嫩 | 麻豆国产一区二区| 在线观看视频欧美| 亚洲欧美另类综合偷拍| 不卡视频免费播放| 国产精品婷婷午夜在线观看| 久久99九九99精品| 日韩美女视频在线| 美美哒免费高清在线观看视频一区二区| 欧美在线视频日韩| 国产乱码精品一区二区三区忘忧草 | 亚洲综合色区另类av| 91影院在线观看| 自拍偷拍亚洲综合| 在线观看精品一区| 亚洲一区二区高清| 欧美日韩久久一区| 天堂一区二区在线| 日韩午夜在线播放| 国产乱对白刺激视频不卡| 欧美精品一区二区三区四区 | 亚洲精品一区二区精华| 极品销魂美女一区二区三区| 久久一区二区三区国产精品| 国产精品影视天天线| 国产免费久久精品| 色欧美片视频在线观看 | 国产精品一区二区在线观看网站| 精品伦理精品一区| 高清不卡一区二区| 亚洲人成影院在线观看| 91.com视频| 国产毛片精品一区| 亚洲欧洲综合另类| 在线不卡免费欧美| 国产精品白丝av| 一区二区三区在线免费播放| 精品视频全国免费看| 奇米精品一区二区三区在线观看| 精品入口麻豆88视频| 成人国产精品免费| 亚洲一区二区五区| 精品福利一区二区三区| 91在线视频免费观看| 亚洲成人在线网站| 国产日产亚洲精品系列| 色嗨嗨av一区二区三区| 蜜桃av一区二区在线观看| 亚洲国产精品99久久久久久久久| 91黄色小视频| 国产精品一级黄| 亚洲国产精品麻豆| 国产精品色在线观看| 7777精品伊人久久久大香线蕉最新版 | 日韩精品每日更新| 中文字幕乱码亚洲精品一区 | 精品一区二区在线播放| 最新不卡av在线| 欧美电影免费观看完整版| www..com久久爱| 免费成人小视频| 亚洲色图.com| 久久综合色天天久久综合图片| 亚洲婷婷综合色高清在线| 日韩欧美高清在线| 欧美偷拍一区二区| 成人毛片视频在线观看| 久草在线在线精品观看| 亚洲777理论| 亚洲日本乱码在线观看| xvideos.蜜桃一区二区| 正在播放亚洲一区| 欧美制服丝袜第一页| www.一区二区| 国产东北露脸精品视频| 麻豆精品久久久| 青青草91视频| 婷婷成人综合网| 亚洲综合在线五月| 自拍偷拍国产亚洲| 亚洲丝袜美腿综合| 国产精品乱人伦| 国产欧美一区二区在线| 精品国产一区二区在线观看| 911精品产国品一二三产区| 欧美在线免费视屏| 在线观看日韩一区| 一本到不卡精品视频在线观看| 国产精品99久久久久久宅男| 九九国产精品视频| 国模套图日韩精品一区二区| 蜜芽一区二区三区| 美女国产一区二区三区| 日韩中文字幕麻豆| 视频一区二区三区在线| 五月婷婷激情综合网| 午夜久久福利影院| 日本欧美一区二区在线观看| 日本在线播放一区二区三区| 日韩精品一二三区| 美女视频免费一区| 精品无人码麻豆乱码1区2区| 国产一区美女在线| 成人av影院在线| 色婷婷综合在线| 欧美剧情片在线观看| 在线不卡免费av| 精品毛片乱码1区2区3区| 国产清纯美女被跳蛋高潮一区二区久久w | 日韩精品影音先锋| 久久五月婷婷丁香社区| 欧美激情中文不卡| 一区二区三区高清在线| 午夜精品福利一区二区蜜股av| 日韩二区三区在线观看| 国产精品综合视频| 91小宝寻花一区二区三区| 欧美在线一区二区| 精品国产青草久久久久福利| 国产精品美女一区二区| 亚洲一区二区三区四区中文字幕| 图片区小说区国产精品视频| 国产一区视频在线看| 91在线小视频| 91精品婷婷国产综合久久竹菊| 久久久久久久一区| 一区二区三区中文在线| 蜜桃视频第一区免费观看| 国产高清无密码一区二区三区| 日本韩国一区二区| 精品黑人一区二区三区久久| 亚洲日穴在线视频| 另类小说综合欧美亚洲| 成人av免费网站| 日韩欧美国产午夜精品| 亚洲欧洲国产日韩| 麻豆精品一区二区av白丝在线| 成人av免费在线| 日韩欧美一二区| 亚洲一二三四区| 国产成人精品一区二区三区四区| 欧美性猛交xxxxxxxx| 久久精品一区二区三区不卡牛牛| 亚洲欧美激情在线| 国产高清精品久久久久| 欧美伊人久久大香线蕉综合69| www精品美女久久久tv| 亚洲狠狠丁香婷婷综合久久久| 久久国产精品99精品国产 | 亚洲va欧美va天堂v国产综合| 国产裸体歌舞团一区二区| 精品视频在线免费看| 国产日韩欧美精品综合| 蜜臀av性久久久久蜜臀av麻豆| 91丨九色丨国产丨porny| 久久久亚洲精华液精华液精华液| 日韩激情一二三区| 在线免费不卡视频| 中文字幕一区二区三区视频| 黑人巨大精品欧美黑白配亚洲| 欧美日韩一本到| 亚洲精品伦理在线| 成人黄动漫网站免费app| 久久影院电视剧免费观看| 日本网站在线观看一区二区三区| 欧美在线视频你懂得| 亚洲综合丁香婷婷六月香| 91免费版pro下载短视频| 国产精品丝袜91| 成人免费高清在线| 欧美精彩视频一区二区三区| 国产伦精品一区二区三区免费 | 日韩美女一区二区三区四区| 丝袜美腿亚洲色图| 欧美日韩你懂的| 亚洲综合视频在线| 欧美日韩综合在线免费观看| 一区二区在线看| 欧美日韩中文字幕精品| 亚洲丰满少妇videoshd| 欧美男同性恋视频网站| 视频一区二区国产|