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

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

?? os_sem.c

?? 這是基于LPC2210芯片的定時器的應用源代碼
?? 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毛片久久久久**hd| 国产精品天干天干在观线| av在线一区二区| 亚洲一区在线电影| 欧美一区二区啪啪| 国产精品456露脸| 亚洲欧洲日产国码二区| 在线观看日产精品| 久久精品国产第一区二区三区| 精品日韩一区二区| 成人国产亚洲欧美成人综合网 | 奇米色777欧美一区二区| 精品少妇一区二区| 91在线观看地址| 午夜电影一区二区| 久久女同精品一区二区| av中文字幕在线不卡| 亚洲va韩国va欧美va精品| 精品三级在线观看| av一区二区三区黑人| 亚洲chinese男男1069| 日韩欧美成人午夜| 99这里都是精品| 日韩国产在线一| 久久精品亚洲一区二区三区浴池| 91日韩精品一区| 看片的网站亚洲| 18欧美亚洲精品| 日韩欧美专区在线| 91免费国产在线观看| 奇米色777欧美一区二区| 亚洲国产激情av| 日韩欧美一级精品久久| 99精品一区二区三区| 久久se精品一区精品二区| 亚洲精品日韩专区silk| 精品国产a毛片| 欧美日韩亚洲综合一区 | 99国产精品一区| 激情综合色播五月| 亚洲一区二区中文在线| 日本一区二区三区电影| 欧美一区二区免费观在线| 一本久久a久久精品亚洲| 狠狠色综合播放一区二区| 亚洲1区2区3区4区| 亚洲精品成人在线| 中国av一区二区三区| 日韩三级在线免费观看| 欧美在线观看你懂的| 国产精品一二三四区| 日韩高清一级片| 亚洲综合小说图片| 国产精品国模大尺度视频| 337p粉嫩大胆噜噜噜噜噜91av| 欧美性受极品xxxx喷水| 91免费看片在线观看| 高清国产午夜精品久久久久久| 久久国产福利国产秒拍| 日韩黄色免费电影| 午夜精品久久久久久久久久| 中文字幕日韩一区| 日韩一区日韩二区| 1区2区3区精品视频| 国产精品久久久久久亚洲伦| 日本一区二区电影| 国产午夜亚洲精品不卡| 精品99999| 2017欧美狠狠色| 久久蜜桃av一区精品变态类天堂 | ww久久中文字幕| 精品国产免费一区二区三区香蕉| 欧美一区二区三区免费大片 | 国产成人av资源| 国产盗摄视频一区二区三区| 精品在线一区二区| 精品一区二区三区久久| 久久激情综合网| 国产一区91精品张津瑜| 激情深爱一区二区| 国产精品一二三四五| 国产不卡视频在线观看| 成人免费av网站| 91在线观看一区二区| 91麻豆成人久久精品二区三区| 91官网在线观看| 欧美人体做爰大胆视频| 欧美一级理论片| 久久久噜噜噜久久中文字幕色伊伊 | 欧美精品日韩精品| 欧美一区二区三区视频在线观看| 91精品国产乱码| 久久夜色精品国产噜噜av| 中文字幕 久热精品 视频在线 | 一区二区久久久| 日韩经典一区二区| 韩国av一区二区三区四区| 国产精品一区二区不卡| 91麻豆视频网站| 欧美日韩另类一区| 精品女同一区二区| 亚洲国产高清不卡| 亚洲成人激情自拍| 国产精品一区二区久久不卡 | 偷偷要91色婷婷| 久久激情五月激情| 91免费观看国产| 91精品国产丝袜白色高跟鞋| 国产偷国产偷精品高清尤物| 亚洲精品日韩一| 精品一区二区在线播放| 99v久久综合狠狠综合久久| 欧美日韩国产首页| 久久久久久久久久久久电影| 一区二区三区四区蜜桃| 久久99精品久久久久婷婷| 97精品国产露脸对白| 91精品国模一区二区三区| 国产免费成人在线视频| 亚洲第一主播视频| 成人性生交大片| 日韩丝袜情趣美女图片| 成人欧美一区二区三区小说 | 欧美军同video69gay| 日本一区二区成人| 蜜桃一区二区三区在线| 99re视频精品| 久久综合色鬼综合色| 亚洲一卡二卡三卡四卡五卡| 国产91在线观看| 欧美一区二区视频免费观看| 成人欧美一区二区三区1314| 老司机午夜精品| 欧美老人xxxx18| 亚洲欧美日韩小说| 国产91丝袜在线观看| 欧美v日韩v国产v| 亚洲国产精品久久人人爱| 成人小视频免费观看| 8x8x8国产精品| 一个色妞综合视频在线观看| 国产一区二区三区四| 日韩一区二区在线观看视频| 玉米视频成人免费看| 99精品欧美一区二区蜜桃免费| 久久日韩精品一区二区五区| 天涯成人国产亚洲精品一区av| 91久久一区二区| 亚洲视频你懂的| 99久久久久久99| 国产人成一区二区三区影院| 麻豆精品久久久| 日韩欧美国产一区在线观看| 三级成人在线视频| 欧美日韩激情一区二区三区| 亚洲精品高清在线观看| 91在线精品一区二区| 国产精品久久久久aaaa| 国产乱码精品一区二区三| 精品99一区二区| 国产精品一区在线| 久久婷婷色综合| 懂色中文一区二区在线播放| 国产视频911| 国产 日韩 欧美大片| 国产精品视频一区二区三区不卡| 国产经典欧美精品| 国产欧美日韩久久| 9色porny自拍视频一区二区| 国产精品进线69影院| 91在线免费视频观看| 亚洲最色的网站| 欧美日韩国产一区二区三区地区| 一区二区高清在线| 欧美丰满美乳xxx高潮www| 日本欧美在线观看| 日韩欧美国产综合| 国产成人精品三级麻豆| 国产日产欧美一区| 色综合久久久久综合体| 性做久久久久久免费观看| 欧美一三区三区四区免费在线看| 蜜臀av性久久久久蜜臀aⅴ流畅| 日韩免费观看高清完整版| 国产伦精一区二区三区| 中文字幕欧美区| 日本韩国欧美一区二区三区| 亚洲大片一区二区三区| 日韩一区二区三区在线视频| 国产一区二区三区免费| 国产精品国产三级国产三级人妇 | 欧美日韩高清一区二区三区| 免费成人结看片| 久久伊人中文字幕| 99re亚洲国产精品| 免费在线观看日韩欧美| 国产欧美日韩卡一| 欧美日韩国产高清一区|