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

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

?? os_sem.c

?? ucosII在TMS320LF2407成功移植的源代碼
?? 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一区二区三区免费野_久草精品视频
日韩欧美一区二区三区在线| 久久久综合视频| 国产精品白丝jk黑袜喷水| **性色生活片久久毛片| 51午夜精品国产| 99久久夜色精品国产网站| 日韩成人av影视| 成人免费一区二区三区在线观看| 7777精品伊人久久久大香线蕉超级流畅 | 欧美美女直播网站| 国产69精品久久久久777| 日韩精品免费专区| 亚洲人成在线播放网站岛国| 欧美videos大乳护士334| 在线一区二区三区四区五区| 国产成人丝袜美腿| 久久不见久久见免费视频1| 亚洲综合久久久| 国产精品久久久久毛片软件| 欧美成人伊人久久综合网| 色婷婷激情久久| 成人午夜电影小说| 韩日av一区二区| 日本女优在线视频一区二区| 五月综合激情日本mⅴ| 欧美激情一区二区三区蜜桃视频| 欧美一级欧美三级在线观看| 欧美综合视频在线观看| 成人福利视频在线看| 国产一区二区三区精品视频| 男女视频一区二区| 日韩国产成人精品| 五月天欧美精品| 亚欧色一区w666天堂| 亚洲一区二区美女| 亚洲免费观看在线观看| 亚洲视频中文字幕| 亚洲欧美精品午睡沙发| 国产精品久久久久久久久免费桃花 | 欧美刺激脚交jootjob| 在线电影国产精品| 色老汉av一区二区三区| 972aa.com艺术欧美| 北条麻妃国产九九精品视频| 国产精品羞羞答答xxdd| 国v精品久久久网| 国产成都精品91一区二区三| 国产不卡视频在线播放| 国产成人午夜精品5599 | 国产乱码一区二区三区| 国产乱码一区二区三区| 成人天堂资源www在线| 国产福利一区二区三区视频在线| 国产美女一区二区| 国产99久久久国产精品免费看| 成人中文字幕电影| 91亚洲精品乱码久久久久久蜜桃 | 国产一区二区h| 国产sm精品调教视频网站| 成人免费视频免费观看| www.亚洲色图.com| 色av成人天堂桃色av| 欧美三级日韩三级| 欧美一级一级性生活免费录像| 日韩欧美国产1| 亚洲国产精品二十页| 亚洲特黄一级片| 婷婷中文字幕综合| 精品一区二区免费在线观看| 国产suv精品一区二区6| 欧美做爰猛烈大尺度电影无法无天| 337p亚洲精品色噜噜噜| 久久久久国产精品免费免费搜索| 国产精品福利一区| 日韩国产一二三区| 国产精品乡下勾搭老头1| 色先锋资源久久综合| 欧美精品久久一区| 国产午夜精品一区二区| 亚洲欧美电影一区二区| 日韩av电影天堂| 国产99久久久国产精品免费看| 91国在线观看| 欧美精品一区二区三区四区| 亚洲免费色视频| 麻豆精品一区二区三区| aa级大片欧美| 日韩午夜三级在线| 中文字幕人成不卡一区| 亚洲h动漫在线| 国产成人三级在线观看| 欧美福利视频一区| 国产天堂亚洲国产碰碰| 亚洲国产aⅴ成人精品无吗| 国产成a人亚洲精品| 欧美精品视频www在线观看| 亚洲国产精华液网站w| 亚洲第一狼人社区| 成人激情图片网| 日韩一区二区影院| 亚洲美女屁股眼交3| 精品一区二区在线播放| 欧美在线一二三四区| 欧美激情综合五月色丁香小说| 男女视频一区二区| 欧美无砖砖区免费| 国产精品的网站| 国产一区二区三区精品视频| 欧美日韩不卡视频| 国产精品高潮呻吟久久| 精品亚洲国内自在自线福利| 91麻豆.com| 国产精品乱码人人做人人爱| 免费高清成人在线| 在线精品视频一区二区三四| 国产精品免费视频一区| av一二三不卡影片| 久久亚洲精品国产精品紫薇| 婷婷综合另类小说色区| 91福利在线导航| 一区在线观看视频| 国产成人在线色| 亚洲v中文字幕| 91美女片黄在线观看| 久久久久久黄色| 日韩va亚洲va欧美va久久| 在线国产亚洲欧美| 亚洲精品成人a在线观看| caoporen国产精品视频| 国产日韩亚洲欧美综合| 国产主播一区二区| 欧美成人在线直播| 精品影视av免费| 26uuu亚洲综合色| 久久成人免费电影| 精品免费国产二区三区 | 91色在线porny| 日本一二三不卡| av一区二区三区黑人| 中文字幕亚洲综合久久菠萝蜜| 国产成人免费在线| 中文字幕欧美日韩一区| 成人中文字幕合集| 亚洲欧洲日韩在线| 94-欧美-setu| 一区二区三区国产| 91麻豆国产福利精品| 夜夜夜精品看看| 欧美日韩国产综合一区二区| 午夜精品在线看| 日韩美一区二区三区| 国产一区二区三区综合 | 五月天欧美精品| 欧美一级国产精品| 国产一区二区三区美女| 欧美激情一区不卡| 91色|porny| 亚洲mv在线观看| 91精品欧美久久久久久动漫| 美女视频黄久久| 久久久久久久久岛国免费| www.久久久久久久久| 亚洲女人小视频在线观看| 欧美亚洲综合另类| 日韩电影在线免费| 精品国产免费一区二区三区四区| 国产在线播放一区| 亚洲日穴在线视频| 欧美精品少妇一区二区三区| 极品少妇xxxx精品少妇偷拍| 中文字幕第一页久久| 色综合久久88色综合天天| 婷婷中文字幕一区三区| 国产亚洲短视频| 精品视频色一区| 激情综合一区二区三区| 中文字幕在线观看不卡| 欧美日韩精品综合在线| 国产伦精品一区二区三区视频青涩| 国产精品福利影院| 欧美一区午夜精品| 成人免费视频播放| 日韩不卡在线观看日韩不卡视频| 国产欧美视频在线观看| 欧美精品日韩一本| 成人久久视频在线观看| 婷婷丁香激情综合| 国产精品视频麻豆| 日韩视频在线永久播放| 色综合天天综合色综合av| 美女网站一区二区| 亚洲免费观看高清| 2020国产精品自拍| 欧美日韩午夜在线| 成人久久久精品乱码一区二区三区| 日本三级韩国三级欧美三级| 综合精品久久久| 久久久欧美精品sm网站| 精品视频一区二区三区免费| 不卡一区中文字幕|