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

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

?? os_sem.c

?? 562uCOS-II_2.52在51上的移植程序
?? 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)
{
   
    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                      */
        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)
{
   
    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电影免费在线播放| 中文字幕日韩精品一区| 亚洲精品一区二区三区精华液| 欧美日韩国产一级片| 在线免费亚洲电影| 欧美天堂亚洲电影院在线播放| 91一区二区在线观看| 成人av动漫在线| 国产福利不卡视频| 成人免费看黄yyy456| 99精品欧美一区二区三区综合在线| 成人av电影在线播放| 色一区在线观看| 欧美日韩一区二区三区在线看| 欧美日韩激情一区| 欧美成人video| 久久精品亚洲乱码伦伦中文| 中文字幕乱码日本亚洲一区二区 | 久久99国产精品久久| 理论片日本一区| 成人性生交大片免费看中文网站| 不卡电影一区二区三区| 色视频成人在线观看免| 欧美乱熟臀69xxxxxx| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 日韩你懂的在线播放| 在线观看成人小视频| 欧美伦理视频网站| 久久午夜色播影院免费高清| 中文字幕日本不卡| 男人的天堂久久精品| 国产精品456| 在线国产电影不卡| 日韩欧美国产综合| 亚洲日本青草视频在线怡红院| 天天综合网天天综合色| 国产一区二区三区最好精华液| 91啪九色porn原创视频在线观看| 欧美人体做爰大胆视频| 中文字幕精品—区二区四季| 日本伊人色综合网| 成人免费高清在线| 日韩女优视频免费观看| 亚洲日本免费电影| 国内精品免费在线观看| 欧美视频一区二区三区四区| 国产精品资源在线看| 91婷婷韩国欧美一区二区| 日韩精品一区在线观看| 亚洲最新视频在线观看| 国产一区二区三区四| 欧美影院一区二区| 国产精品久久久久影视| 精品午夜一区二区三区在线观看| 在线视频一区二区免费| 国产精品伦一区| 韩国v欧美v日本v亚洲v| 在线综合+亚洲+欧美中文字幕| 18成人在线观看| 丁香桃色午夜亚洲一区二区三区| 欧美日韩国产大片| 亚洲精品国产a久久久久久| 丰满少妇久久久久久久| 欧美zozozo| 久久精品国产澳门| 91精品国产黑色紧身裤美女| 亚洲午夜日本在线观看| 色综合视频在线观看| 一区免费观看视频| 成人av在线资源| 国产精品二三区| 成人高清视频在线观看| 欧美国产日韩a欧美在线观看| 精品亚洲免费视频| 亚洲精品在线观| 精品一区二区免费看| 精品少妇一区二区三区在线播放 | 亚洲高清免费视频| 欧美婷婷六月丁香综合色| 亚洲精品视频在线观看网站| 色吊一区二区三区| 亚洲午夜免费视频| 欧美军同video69gay| 图片区小说区区亚洲影院| 欧美久久久久久蜜桃| 天天亚洲美女在线视频| 日韩欧美国产综合一区| 狠狠狠色丁香婷婷综合激情 | 粉嫩高潮美女一区二区三区| 国产午夜精品在线观看| 成人免费观看男女羞羞视频| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 日韩成人一区二区三区在线观看| 欧美精品日韩综合在线| 毛片一区二区三区| 国产精品网曝门| 日本韩国视频一区二区| 日韩一区精品视频| 久久综合网色—综合色88| 成人午夜视频免费看| 亚洲日本va午夜在线影院| 欧美精品久久久久久久久老牛影院| 美女视频黄a大片欧美| 国产欧美日本一区视频| 91色婷婷久久久久合中文| 亚洲va在线va天堂| 欧美激情在线看| 欧美色精品天天在线观看视频| 麻豆专区一区二区三区四区五区| 国产精品网站一区| 欧美三级一区二区| 国产在线观看免费一区| 亚洲精品欧美二区三区中文字幕| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 美女一区二区三区| 亚洲另类在线视频| 久久免费电影网| 欧美精品乱人伦久久久久久| 国产suv精品一区二区6| 天天综合网天天综合色| 国产精品天干天干在线综合| 91精品欧美综合在线观看最新| 丰满亚洲少妇av| 免费在线成人网| 亚洲一区二区av在线| 国产日产欧美一区| 日韩免费视频线观看| 日本道精品一区二区三区| 国产激情视频一区二区三区欧美| 亚洲超碰精品一区二区| 亚洲免费色视频| 国产三级久久久| 2022国产精品视频| 5566中文字幕一区二区电影| 91蜜桃免费观看视频| 粗大黑人巨茎大战欧美成人| 久久成人久久鬼色| 五月天中文字幕一区二区| 伊人开心综合网| 日韩毛片视频在线看| 国产欧美一区二区在线观看| 日韩精品一区二区三区三区免费| 欧美日韩一二三区| 日本道色综合久久| 99国产精品久久| 99精品视频在线观看| 成人在线视频一区| 成人听书哪个软件好| 国产91精品免费| 粉嫩aⅴ一区二区三区四区五区| 精品一区二区三区免费观看| 久久精品国产网站| 麻豆国产欧美一区二区三区| 日本欧洲一区二区| 蜜臀va亚洲va欧美va天堂 | 国产综合色产在线精品| 麻豆久久一区二区| 精品午夜一区二区三区在线观看| 理论片日本一区| 国产高清不卡一区二区| 大尺度一区二区| 91美女片黄在线| 欧美色国产精品| 日韩欧美一二三四区| 日韩欧美激情在线| 国产农村妇女毛片精品久久麻豆| 国产欧美一区二区三区网站| 欧美国产一区二区在线观看| 亚洲人成在线观看一区二区| 一区二区免费看| 人人爽香蕉精品| 国产精品资源在线| 91性感美女视频| 欧美一区二区三区视频在线观看| 精品免费99久久| 综合在线观看色| 午夜久久福利影院| 国产最新精品精品你懂的| 成人av综合一区| 欧美久久免费观看| 久久精品一二三| 亚洲国产另类av| 国产一区二区不卡| 欧美亚洲国产一区在线观看网站| 日韩欧美电影一区| 中文字幕第一区| 三级不卡在线观看| 国产精品白丝av| 欧美色手机在线观看| 久久综合给合久久狠狠狠97色69| 中文字幕一区二区三区视频| 日韩精品色哟哟| 91免费小视频| 久久久午夜电影| 亚洲午夜三级在线| 成人av资源网站| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 亚洲va天堂va国产va久| 丝袜亚洲精品中文字幕一区|