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

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

?? os_sem.c

?? ucosII for ARM4510B
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2001, 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)
{
    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)
{
    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                      */
        OS_EventWaitListInit(pevent);
    }
    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)
{
    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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美激情小说另类| 丝袜美腿一区二区三区| 亚洲成人一区在线| 激情图区综合网| 91猫先生在线| 91精品国产91综合久久蜜臀| 精品久久久久久久久久久久包黑料 | 99精品久久久久久| 欧美电影一区二区| 中文字幕av资源一区| 91欧美一区二区| 久久亚洲精品国产精品紫薇| 一色屋精品亚洲香蕉网站| 蜜臀av性久久久久蜜臀av麻豆 | 国产91丝袜在线播放九色| 欧洲一区二区av| 中文字幕精品—区二区四季| 日韩高清欧美激情| 色哟哟欧美精品| 欧美韩国一区二区| 精品一区二区三区免费视频| 欧美视频在线不卡| 亚洲免费在线播放| 国产精品小仙女| 日韩美女一区二区三区四区| 夜夜嗨av一区二区三区四季av| 国产毛片精品国产一区二区三区| 欧美日本一区二区三区四区| 亚洲手机成人高清视频| 91视频com| 国产精品人成在线观看免费| 国产精品一区在线| 精品国产伦一区二区三区免费 | 国模一区二区三区白浆| 91精品国产日韩91久久久久久| 亚洲欧美日韩一区二区| 99视频一区二区| 综合av第一页| 日本黄色一区二区| 亚洲国产综合在线| 欧美日韩中文另类| 日日摸夜夜添夜夜添精品视频 | 欧美精品丝袜久久久中文字幕| 一区二区高清视频在线观看| 99re视频精品| 性久久久久久久| 日韩一区二区麻豆国产| 久久www免费人成看片高清| 久久精品视频免费| 色综合久久99| 日本亚洲视频在线| 国产欧美一区二区精品仙草咪| 国产麻豆精品视频| 亚洲欧美国产高清| 日韩精品一区国产麻豆| 国产精品一区在线观看你懂的| 日本一区二区电影| 欧洲色大大久久| 美女一区二区久久| 国产精品电影院| 欧美日韩aaaaaa| av亚洲精华国产精华精华| 亚洲最大成人网4388xx| 国产日韩欧美一区二区三区综合| 91尤物视频在线观看| 另类小说欧美激情| 一区二区三区在线观看动漫| 欧美成va人片在线观看| 欧美三级韩国三级日本一级| 国产一区在线精品| 日韩电影免费一区| 国产精品女主播在线观看| 亚洲一区二区三区小说| 国内外成人在线视频| 亚洲一区二区三区视频在线| 亚洲欧洲日韩av| 亚洲国产精品精华液2区45| 欧美一区在线视频| 日本高清免费不卡视频| 成人国产精品视频| 国产99久久久国产精品潘金| 免费欧美在线视频| 婷婷丁香久久五月婷婷| 亚洲精品国产a| 免费成人av资源网| 伊人色综合久久天天人手人婷| 久久久久88色偷偷免费| 精品美女被调教视频大全网站| 欧美一区二区成人| 欧美一区二区大片| 欧美不卡123| 久久伊99综合婷婷久久伊| 精品91自产拍在线观看一区| 精品日韩一区二区| 久久久国际精品| 亚洲色欲色欲www| 一区二区三区日韩精品视频| 亚洲图片欧美一区| 毛片一区二区三区| 国产99久久久久| 91蜜桃网址入口| 在线欧美日韩国产| 3d动漫精品啪啪1区2区免费| 日韩久久久久久| 亚洲国产精品激情在线观看| 中文字幕一区二区视频| 亚洲在线中文字幕| 精品一区二区日韩| 波多野洁衣一区| 精品视频1区2区3区| 久久蜜桃一区二区| 亚洲伊人伊色伊影伊综合网| 免费国产亚洲视频| 成人不卡免费av| 91麻豆精品91久久久久久清纯| 久久久久99精品国产片| 有码一区二区三区| 精品亚洲国内自在自线福利| 99久久久久免费精品国产| 欧美一卡二卡在线观看| 国产精品九色蝌蚪自拍| 免费在线视频一区| 欧洲激情一区二区| 免费看日韩精品| 不卡一区二区三区四区| 欧美精品日韩精品| 中文字幕成人av| 久久99精品久久久久久久久久久久| 国产成人超碰人人澡人人澡| 欧美一级理论性理论a| 国产精品久久久久7777按摩| 麻豆精品视频在线| 欧美这里有精品| 国产精品国产三级国产aⅴ原创| 欧美在线综合视频| 亚洲精品中文字幕在线观看| 国产剧情一区二区| 日韩视频免费观看高清完整版在线观看 | 激情国产一区二区| 91精品国产黑色紧身裤美女| 亚洲一区二区三区中文字幕| av在线不卡免费看| 欧美国产成人精品| 国产jizzjizz一区二区| 久久这里只有精品首页| 蜜臀av国产精品久久久久| 日韩一本二本av| 日韩精品一卡二卡三卡四卡无卡| 欧美视频一区在线观看| 婷婷综合五月天| 欧美一区二区视频在线观看2020| 亚洲国产精品欧美一二99| 欧美日韩高清不卡| 热久久免费视频| 久久色中文字幕| 国产麻豆成人传媒免费观看| 精品少妇一区二区三区免费观看| 免费精品视频在线| 欧美激情中文字幕| 色综合久久中文综合久久97| 一区二区不卡在线播放| 日韩午夜激情免费电影| 国产精品99久久久久久似苏梦涵 | 亚洲成年人网站在线观看| 日韩一区二区三区高清免费看看| 蜜桃久久精品一区二区| 中文字幕av资源一区| 欧美性videosxxxxx| 美女视频网站黄色亚洲| 国产精品久久久久久久久图文区| 在线精品亚洲一区二区不卡| 麻豆精品在线播放| 中日韩免费视频中文字幕| 在线欧美日韩国产| 国产在线日韩欧美| 亚洲综合区在线| 久久久久久亚洲综合| 91福利视频久久久久| 精品一区二区三区久久| 亚洲男人的天堂av| 2024国产精品| 7777女厕盗摄久久久| 成人免费av网站| 久久av老司机精品网站导航| 国产精品入口麻豆九色| 欧美成人精品福利| 91久久精品网| 丁香桃色午夜亚洲一区二区三区| 艳妇臀荡乳欲伦亚洲一区| 久久久激情视频| 日韩精品资源二区在线| 欧美特级限制片免费在线观看| 不卡av免费在线观看| 国产精品一区三区| 日产欧产美韩系列久久99| 一区二区三区日韩在线观看| 国产精品久久久久久久久免费桃花| 日韩欧美国产不卡| 日韩精品专区在线| 欧美r级电影在线观看|