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

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

?? os_sem.c

?? protues仿真ARM ARM的I2C
?? 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一区二区三区免费野_久草精品视频
欧美日精品一区视频| av成人动漫在线观看| 亚洲国产精品一区二区久久恐怖片| 精品国产伦理网| 亚洲精品一区二区三区99| 欧美精品一区二区三区在线| 日韩三级av在线播放| 欧美一级欧美一级在线播放| 制服丝袜一区二区三区| 日韩一区二区三区高清免费看看 | 欧美成va人片在线观看| 69久久夜色精品国产69蝌蚪网| 欧美性xxxxxx少妇| 56国语精品自产拍在线观看| 欧美精品xxxxbbbb| 26uuu国产电影一区二区| 久久久久国产免费免费| 国产精品污污网站在线观看| 亚洲三级视频在线观看| 亚洲成av人片一区二区| 蜜桃视频在线一区| 国产精品一二一区| 91麻豆免费视频| 欧美精品久久天天躁| 欧美xxxx在线观看| 亚洲特级片在线| 天天综合天天综合色| 精彩视频一区二区三区| 成人永久aaa| 欧美精品三级在线观看| 久久精品免费在线观看| 亚洲国产精品综合小说图片区| 青草国产精品久久久久久| 国产一区二区三区蝌蚪| 91亚洲精品一区二区乱码| 91精品国产综合久久精品app| www国产亚洲精品久久麻豆| 国产精品女同一区二区三区| 亚洲国产成人av| 国产aⅴ综合色| 一本色道a无线码一区v| 91精品黄色片免费大全| 中文av字幕一区| 伦理电影国产精品| 欧美偷拍一区二区| 国产精品视频看| 久久69国产一区二区蜜臀| 一本色道**综合亚洲精品蜜桃冫| 精品国产一区二区精华| 亚洲综合av网| 成人av网址在线观看| 日韩一二在线观看| 亚洲一区二区三区三| 成人免费av网站| 26uuu欧美| 久久国产精品一区二区| 欧美日韩激情一区二区| 亚洲视频图片小说| 风间由美一区二区三区在线观看| 欧美精品色一区二区三区| 一个色综合av| 91最新地址在线播放| 国产人伦精品一区二区| 精品影院一区二区久久久| 日韩欧美另类在线| 日本va欧美va精品| 777久久久精品| 一级做a爱片久久| 在线视频欧美精品| 最新国产の精品合集bt伙计| 国产ts人妖一区二区| 国产日韩欧美综合一区| 国产一区二区网址| 国产三级精品在线| 国产精品456| 中文在线一区二区| 成人激情动漫在线观看| 国产精品理伦片| 粉嫩在线一区二区三区视频| 久久久夜色精品亚洲| 国产一区二区0| 久久久久久久久久久久久夜| 国产资源在线一区| 国产精品三级视频| 91在线观看成人| 亚洲午夜电影在线| 91精品国产色综合久久| 久久66热偷产精品| 亚洲国产精品成人久久综合一区| 成人免费视频app| 一区二区成人在线视频| 欧美嫩在线观看| 成人午夜视频福利| 中文字幕中文字幕一区| 在线观看三级视频欧美| 免费在线视频一区| 久久久久久97三级| 色婷婷综合激情| 日韩成人精品视频| 欧美国产乱子伦 | 91久久线看在观草草青青| 亚洲欧美日韩国产成人精品影院| 在线观看一区日韩| 九九精品一区二区| 亚洲精品视频免费看| 欧美男男青年gay1069videost | 亚洲欧洲中文日韩久久av乱码| 99精品久久99久久久久| 日韩成人精品在线| 亚洲国产精品t66y| 欧美理论在线播放| 国产成人精品免费网站| 亚洲免费观看高清完整版在线| 91精品国产一区二区三区| 福利电影一区二区| 奇米精品一区二区三区在线观看 | 国产成人精品亚洲午夜麻豆| 亚洲欧美色一区| 亚洲精品一区二区三区四区高清| 91同城在线观看| 国产精品77777| 午夜精品免费在线观看| 中文一区在线播放| 欧美一区二区免费视频| 色先锋久久av资源部| 激情亚洲综合在线| 日本在线播放一区二区三区| 国产精品国产三级国产普通话99 | 69av一区二区三区| 91在线视频观看| 国模大尺度一区二区三区| 亚洲综合一区二区精品导航| 国产欧美精品一区二区三区四区| 91精品婷婷国产综合久久竹菊| 91在线精品秘密一区二区| 精品一区二区三区欧美| 日韩中文字幕麻豆| 亚洲国产视频网站| 亚洲精品日日夜夜| 中日韩av电影| 国产欧美va欧美不卡在线| 日韩一区二区三区电影| 欧美日韩国产综合一区二区| 91免费版在线| 91麻豆精品秘密| 成人av网站在线观看免费| 国产成人精品免费| 国产美女在线精品| 国产成人综合自拍| 国产iv一区二区三区| 岛国一区二区在线观看| 国产一区二区调教| 国产成人自拍网| 懂色av一区二区三区免费看| 国产在线国偷精品免费看| 国产真实乱子伦精品视频| 久久91精品国产91久久小草| 久久99精品久久久久久国产越南| 蜜桃视频免费观看一区| 激情综合色综合久久| 韩日欧美一区二区三区| 国产精品亚洲一区二区三区妖精 | 国产盗摄视频一区二区三区| 韩国精品一区二区| 国产成人av电影在线| 国产不卡视频在线观看| 成人短视频下载| 91玉足脚交白嫩脚丫在线播放| 色偷偷88欧美精品久久久| 欧美在线|欧美| 在线不卡中文字幕| 精品国产伦一区二区三区免费| 久久免费视频一区| 国产精品国模大尺度视频| 亚洲资源在线观看| 免费看精品久久片| 成人午夜免费电影| 欧美日韩一区二区三区高清| 制服丝袜激情欧洲亚洲| 91精品在线一区二区| 欧美一区二区精品在线| 久久99国产精品久久99果冻传媒| 亚洲欧洲中文日韩久久av乱码| 一区2区3区在线看| 久久精品国产在热久久| 成人国产精品免费| 欧美日本在线观看| 国产精品日日摸夜夜摸av| 一区二区三区国产精华| 精品夜夜嗨av一区二区三区| 成人性色生活片| 91精品国产高清一区二区三区 | 色88888久久久久久影院按摩 | 久久国产免费看| 99国产精品久久| 日韩欧美国产午夜精品| 18成人在线视频| 国产一区啦啦啦在线观看| 欧美中文字幕久久| 中文字幕免费观看一区|