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

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

?? os_sem.c

?? PIC18F452下的uCOS2移植成功代碼+MPLAB IDE V8.0的項目文件。結構非常精簡
?? 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一区二区三区免费野_久草精品视频
成人免费视频国产在线观看| 一区在线播放视频| 青青青伊人色综合久久| 欧美视频第二页| 视频在线在亚洲| 欧美一二三在线| 国产毛片精品一区| 亚洲欧洲精品天堂一级| 欧美在线制服丝袜| 免费观看久久久4p| 中文一区一区三区高中清不卡| 不卡av在线免费观看| 一个色妞综合视频在线观看| 欧美一区二区三区在线电影| 激情深爱一区二区| 国产精品久久久久久久久免费桃花 | 欧美伊人久久久久久久久影院 | 国产精品国产精品国产专区不片| av成人免费在线| 午夜激情一区二区| 久久蜜桃av一区二区天堂 | 国产在线精品视频| 亚洲人成影院在线观看| 欧美剧情片在线观看| 福利视频网站一区二区三区| 亚洲激情图片小说视频| 91精品国产91久久久久久一区二区| 国产精品1区2区3区| 国产精品白丝jk白祙喷水网站| 中文字幕中文字幕在线一区| 制服丝袜av成人在线看| 国产一区在线精品| 不卡的av在线| 一区二区三区日韩欧美精品| 日韩欧美一级二级三级| jlzzjlzz亚洲女人18| 亚洲国产精品影院| 国产欧美日韩三级| 在线成人免费观看| 99精品久久免费看蜜臀剧情介绍| 日韩高清在线一区| 一区二区三区在线播放| 久久久99免费| 欧美精品精品一区| 91久久香蕉国产日韩欧美9色| 精品中文av资源站在线观看| 国产视频亚洲色图| 欧美熟乱第一页| 99这里只有久久精品视频| 麻豆精品视频在线观看免费 | 成人免费av资源| 久久精品国产成人一区二区三区| 亚洲黄色在线视频| 国产精品国模大尺度视频| 久久综合久久鬼色| 欧美一区二区三区小说| 欧美视频一区二区| 色噜噜狠狠成人中文综合| 国产成人免费高清| 国产一区二区中文字幕| 久久草av在线| 免费观看在线综合色| 首页亚洲欧美制服丝腿| 亚洲电影中文字幕在线观看| 亚洲欧洲综合另类在线| 亚洲图片另类小说| 一区免费观看视频| 亚洲欧美中日韩| 中文字幕一区二区视频| 国产精品女上位| 国产清纯美女被跳蛋高潮一区二区久久w| 日韩精品一区二区在线| 日韩一区二区影院| 欧美成人精品3d动漫h| 欧美一卡二卡三卡| 91精品国产综合久久精品app | 欧美成人性福生活免费看| 欧美日韩成人在线| 欧美日韩一区不卡| 亚洲天堂av老司机| 亚洲丝袜精品丝袜在线| 樱桃国产成人精品视频| 亚洲图片欧美综合| 视频一区二区国产| 久久狠狠亚洲综合| 国产传媒日韩欧美成人| 成人精品一区二区三区中文字幕| 成人免费不卡视频| 91精品福利视频| 69堂成人精品免费视频| 欧美大片免费久久精品三p| 精品国产一区二区三区av性色| 精品国产乱码91久久久久久网站| 国产午夜精品福利| 亚洲色图视频网| 日韩精品一卡二卡三卡四卡无卡| 青青草国产精品亚洲专区无| 韩国在线一区二区| jvid福利写真一区二区三区| 欧美色欧美亚洲另类二区| 欧美一三区三区四区免费在线看 | 99精品视频一区| 欧美中文字幕不卡| 日韩精品中文字幕在线一区| 国产精品污网站| 一区二区久久久久久| 久热成人在线视频| 99久久久久免费精品国产| 欧美日韩午夜影院| 久久久久久久精| 亚洲中国最大av网站| 久久精品国产99久久6| 粉嫩嫩av羞羞动漫久久久| 欧美在线不卡一区| 久久久久九九视频| 亚洲va在线va天堂| 丰满岳乱妇一区二区三区| 在线不卡的av| 国产精品色在线观看| 日韩电影在线观看一区| 成人一区二区在线观看| 在线成人小视频| 国产精品第四页| 另类小说综合欧美亚洲| 91小视频在线| www成人在线观看| 亚洲成在人线在线播放| 国产 日韩 欧美大片| 日韩一区二区三| 亚洲综合激情小说| 成人app网站| 久久亚洲免费视频| 丝袜美腿成人在线| 99精品视频一区二区| 久久精品夜色噜噜亚洲aⅴ| 天天av天天翘天天综合网色鬼国产 | 精品综合免费视频观看| 欧美影视一区在线| 日韩美女视频19| 福利一区二区在线| 久久众筹精品私拍模特| 免费在线一区观看| 欧美影片第一页| 亚洲啪啪综合av一区二区三区| 国产不卡在线播放| 五月综合激情网| 99精品视频在线播放观看| 国产午夜久久久久| 紧缚奴在线一区二区三区| 欧美久久久影院| 亚洲成人激情社区| 欧美性欧美巨大黑白大战| 《视频一区视频二区| 成人精品鲁一区一区二区| 国产日韩欧美麻豆| 国产裸体歌舞团一区二区| 久久综合久久99| 国产一区二区三区蝌蚪| 精品99999| 国内精品伊人久久久久影院对白| 91精品婷婷国产综合久久| 午夜视频在线观看一区二区三区| 欧美在线免费观看视频| 亚洲综合在线免费观看| 91色九色蝌蚪| 亚洲欧美日韩国产一区二区三区| 99久久国产综合精品麻豆 | 亚洲午夜免费电影| 91福利区一区二区三区| 亚洲综合在线视频| 欧美日本国产视频| 日日噜噜夜夜狠狠视频欧美人| 欧美色图在线观看| 日韩av一区二区在线影视| 日韩欧美成人午夜| 国产美女av一区二区三区| 国产精品区一区二区三| 91啦中文在线观看| 亚洲va国产天堂va久久en| 91精品国产91久久久久久一区二区 | 久久精品视频在线看| 成人免费毛片app| 亚洲男人的天堂av| 欧美日韩一区二区在线视频| 日韩电影免费在线看| 久久综合一区二区| 91在线丨porny丨国产| 一级日本不卡的影视| 欧美一区二区三区四区视频| 国产一区二区视频在线播放| 国产精品进线69影院| 欧美天堂一区二区三区| 精品在线免费观看| 国产精品福利一区| 69堂精品视频| 成人晚上爱看视频| 亚洲成a人片综合在线| 久久一区二区三区四区| 91国偷自产一区二区使用方法| 丝袜亚洲另类欧美综合|