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

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

?? os_sem.c

?? 基于ADS1.2環境編寫的UC/OS-II的移植源代碼
?? 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);
    }
#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)
{
#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                */
#if OS_EVENT_NAME_SIZE > 0
        (void)strcpy(pevent->OSEventName, "?");
#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)
{
#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);
    }
#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 > 0
                 (void)strcpy(pevent->OSEventName, "?");   /* Unknown name                             */
#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    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
#if OS_EVENT_NAME_SIZE > 0
             (void)strcpy(pevent->OSEventName, "?");       /* Unknown name                             */
#endif
             OS_EventWaitListInit(pevent);                 /* Clear out the wait list                  */
             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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
最新欧美精品一区二区三区| 国产a精品视频| 亚洲精品在线观看网站| 欧美专区亚洲专区| 99国内精品久久| av一区二区三区| 97久久精品人人做人人爽| 国产成人鲁色资源国产91色综 | 91女人视频在线观看| 不卡视频免费播放| 成人国产精品免费观看| 欧美午夜片在线观看| 3atv在线一区二区三区| 欧美日韩国产一级二级| 欧美一三区三区四区免费在线看| 日韩欧美成人激情| 国产喂奶挤奶一区二区三区| 国产精品乱人伦| 亚洲激情成人在线| 日日欢夜夜爽一区| 国产乱子轮精品视频| 成人免费毛片嘿嘿连载视频| 91麻豆成人久久精品二区三区| 色狠狠综合天天综合综合| 欧美日韩一区二区三区高清| 日韩午夜在线观看| 国产精品二区一区二区aⅴ污介绍| 成人免费在线播放视频| 亚洲成人激情社区| 韩国精品免费视频| 色婷婷综合久久久中文字幕| 日韩久久精品一区| 亚洲欧美激情一区二区| 人人精品人人爱| 不卡高清视频专区| 91精品国产一区二区三区| 久久久99精品久久| 午夜欧美在线一二页| 成人免费毛片app| 4hu四虎永久在线影院成人| 国产亚洲精久久久久久| 成人教育av在线| 色8久久精品久久久久久蜜| 欧美精品一二三| 国产女人aaa级久久久级| 五月婷婷激情综合网| 懂色一区二区三区免费观看| 欧美日韩www| 国产精品天干天干在线综合| 日韩av不卡一区二区| 99久久精品一区| 国产亚洲综合色| 视频一区二区三区中文字幕| 91影院在线观看| 精品欧美久久久| 久久99日本精品| 91麻豆免费观看| 亚洲一区二区三区自拍| 99久久久久久| 欧美大度的电影原声| 亚洲激情一二三区| 国产mv日韩mv欧美| 久久综合九色综合97婷婷| 日韩国产在线观看| 欧美精品日韩精品| 一区二区三区影院| 99久久精品国产一区二区三区| 久久影院午夜片一区| 老司机精品视频线观看86| 欧美三级日韩在线| 亚洲国产精品一区二区www在线| 99久久国产综合色|国产精品| 欧美国产成人精品| 成人网在线播放| 欧美国产日产图区| 成人性色生活片| 国产精品视频一二三区| 成人免费福利片| 中文字幕一区二区三区乱码在线| 成人深夜在线观看| 国产精品国产三级国产aⅴ入口| 成人的网站免费观看| 久久久久久久久久久久电影 | 日韩欧美视频一区| 日本中文一区二区三区| 欧美一级xxx| 日本在线观看不卡视频| 欧美性三三影院| 日韩电影一区二区三区四区| 欧美日韩精品一区二区天天拍小说| 亚洲精品国产无天堂网2021 | 亚洲小说欧美激情另类| 欧美午夜在线一二页| 一个色综合网站| 51精品视频一区二区三区| 捆绑调教美女网站视频一区| 3d动漫精品啪啪1区2区免费| 五月婷婷综合激情| 欧美成va人片在线观看| 国产乱码精品一区二区三区av| 精品福利av导航| 成人性视频免费网站| 亚洲三级理论片| 在线成人午夜影院| 精品一区二区在线播放| 国产精品乱码妇女bbbb| 91免费观看视频在线| 亚洲在线观看免费| 欧美大片免费久久精品三p| 成人精品视频.| 亚洲日本丝袜连裤袜办公室| 欧美婷婷六月丁香综合色| 久久99久久99| 国产精品麻豆久久久| 欧美人狂配大交3d怪物一区| 韩国毛片一区二区三区| 亚洲色图.com| 欧美精品九九99久久| 成人免费三级在线| 石原莉奈在线亚洲二区| 国产精品成人免费在线| 555夜色666亚洲国产免| 9i在线看片成人免费| 黑人巨大精品欧美一区| 亚洲3atv精品一区二区三区| 久久精品人人做人人综合| 欧美性videosxxxxx| 国产91精品露脸国语对白| 日本女优在线视频一区二区| 国产精品对白交换视频| 欧美成人高清电影在线| 另类调教123区| 亚洲一区二区欧美| 欧美激情一区二区| 精品国产一二三区| 欧美日韩亚洲综合在线| 91香蕉视频污| 成人精品高清在线| 久久av资源网| 蜜臀av亚洲一区中文字幕| 亚洲一线二线三线久久久| 国产午夜精品理论片a级大结局| 欧美一区二区三区影视| 欧美日韩一区二区三区高清| 在线观看视频一区二区| 91蜜桃视频在线| 懂色av一区二区夜夜嗨| 国产福利91精品一区二区三区| 日韩在线一二三区| 日本亚洲欧美天堂免费| 午夜欧美一区二区三区在线播放| 日韩二区三区四区| 亚洲一区二区三区四区在线观看| 一区二区在线免费| 亚洲欧美中日韩| 亚洲精品少妇30p| 亚洲日本青草视频在线怡红院| 中文字幕视频一区| 亚洲天堂精品在线观看| 亚洲狠狠丁香婷婷综合久久久| 亚洲一区二三区| 丝袜诱惑亚洲看片| 美腿丝袜一区二区三区| 久草中文综合在线| 国产乱一区二区| 972aa.com艺术欧美| 欧洲另类一二三四区| 欧美欧美午夜aⅴ在线观看| 欧美二区三区91| 欧美一区在线视频| 久久久精品欧美丰满| 国产精品久久99| 一区二区三区四区在线| 亚洲h在线观看| 国内一区二区视频| 99re这里都是精品| 欧美区在线观看| 精品理论电影在线观看| 国产精品污污网站在线观看| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲一区二区视频在线| 久久99最新地址| 99热国产精品| 欧美亚洲一区二区三区四区| 欧美一区二区三区在线观看 | 中文字幕在线不卡一区| 综合久久综合久久| 丝袜美腿亚洲一区| 国产一区二区成人久久免费影院| 99久久久久久99| 欧美一级久久久久久久大片| 欧美xxx久久| 国产精品美女久久久久久久| 丝袜亚洲精品中文字幕一区| 国产91在线观看丝袜| 欧美日本韩国一区二区三区视频 | 久久综合给合久久狠狠狠97色69| 亚洲人xxxx| 国产一区二区三区免费播放| 欧美网站一区二区|