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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_sem.c

?? ucos porting source for Am188
?? C
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
*                                           All Rights Reserved
*
*                                                  V2.00
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.h"
#endif

#if OS_SEM_EN
/*
*********************************************************************************************************
*                                           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,
*                         you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

INT16U OSSemAccept (OS_EVENT *pevent)
{
    INT16U cnt;


    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        return (0);
    }
    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                        */
}

/*$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;


    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                      */
        OSEventWaitListInit(pevent);
    }
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                           PEND ON SEMAPHORE
*
* Description: This function waits for a semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore.
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for the resource up to the amount of time specified by this argument.  
*                            If you specify 0, however, your task will wait forever at the specified 
*                            semaphore or, until the resource becomes available (or the event occurs).
*
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_NO_ERR          The call was successful and your task owns the resource 
*                                               or, the event you are waiting for occurred.
*                            OS_TIMEOUT         The semaphore was not received within the specified 
*                                               timeout.
*                            OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR    If you called this function from an ISR and the result
*                                               would lead to a suspension.
*
* Returns    : none
*********************************************************************************************************
*/

void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        *err = OS_ERR_EVENT_TYPE;
    }
    if (pevent->OSEventCnt > 0) {                     /* If sem. is positive, resource available ...   */
        pevent->OSEventCnt--;                         /* ... decrement semaphore only if positive.     */
        OS_EXIT_CRITICAL();
        *err = OS_NO_ERR;
    } else if (OSIntNesting > 0) {                    /* See if called from ISR ...                    */
        OS_EXIT_CRITICAL();                           /* ... can't PEND from an ISR                    */
        *err = OS_ERR_PEND_ISR;
    } else {                                          /* Otherwise, must wait until event occurs       */
        OSTCBCur->OSTCBStat    |= OS_STAT_SEM;        /* Resource not available, pend on semaphore     */
        OSTCBCur->OSTCBDly      = timeout;            /* Store pend timeout in TCB                     */
        OSEventTaskWait(pevent);                      /* Suspend task until event or timeout occurs    */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find next highest priority task ready         */
        OS_ENTER_CRITICAL();
        if (OSTCBCur->OSTCBStat & OS_STAT_SEM) {      /* Must have timed out if still waiting for event*/
            OSEventTO(pevent);
            OS_EXIT_CRITICAL();
            *err = OS_TIMEOUT;                        /* Indicate that didn't get event within TO      */
        } else {
            OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
            OS_EXIT_CRITICAL();
            *err = OS_NO_ERR;
        }
    }
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                         POST TO A SEMAPHORE
*
* Description: This function signals a semaphore
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore.
*
* Returns    : OS_NO_ERR          The call was successful and the semaphore was signaled.
*              OS_SEM_OVF         If the semaphore count exceeded its limit.  In other words, you have 
*                                 signalled the semaphore more often than you waited on it with either
*                                 OSSemAccept() or OSSemPend().
*              OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

INT8U OSSemPost (OS_EVENT *pevent)
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    if (pevent->OSEventGrp) {                              /* See if any task waiting for semaphore    */
        OSEventTaskRdy(pevent, (void *)0, OS_STAT_SEM);    /* Ready highest prio task waiting on event */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find highest priority task ready to run       */
        return (OS_NO_ERR);
    } else {
        if (pevent->OSEventCnt < 65535) {             /* Make sure semaphore will not overflow         */
            pevent->OSEventCnt++;                     /* Increment semaphore count to register event   */
            OS_EXIT_CRITICAL();
            return (OS_NO_ERR);
        } else {                                      /* Semaphore value has reached its maximum       */
            OS_EXIT_CRITICAL();
            return (OS_SEM_OVF);
        }
    }
}
/*
*********************************************************************************************************
*                                          QUERY A SEMAPHORE
*
* Description: This function obtains information about a semaphore
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore
*
*              pdata         is a pointer to a structure that will contain information about the 
*                            semaphore.
*
* Returns    : OS_NO_ERR          The call was successful and the message was sent
*              OS_ERR_EVENT_TYPE  If you are attempting to obtain data from a non semaphore.
*********************************************************************************************************
*/

INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *pdata)
{
    INT8U  i;
    INT8U *psrc;
    INT8U *pdest;
    
    
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OS_ERR_EVENT_TYPE);
    }
    pdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &pdata->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    pdata->OSCnt      = pevent->OSEventCnt;                /* Get semaphore count                      */
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久成人免费网| 欧美韩日一区二区三区四区| 亚洲国产综合视频在线观看| 91麻豆精品一区二区三区| 一区二区三区四区视频精品免费| 色婷婷综合久久久久中文一区二区| 亚洲精品日韩综合观看成人91| 欧洲一区二区三区在线| 亚洲风情在线资源站| 在线电影国产精品| 紧缚奴在线一区二区三区| 久久综合999| av一本久道久久综合久久鬼色| 亚洲视频一二三区| 精品视频999| 美腿丝袜亚洲三区| 中文字幕欧美国产| 在线亚洲欧美专区二区| 日韩不卡在线观看日韩不卡视频| 精品久久久久久无| 99久久精品免费看| 亚洲v日本v欧美v久久精品| 日韩免费在线观看| 成人av手机在线观看| 亚洲成人一区在线| 久久久久久影视| 99v久久综合狠狠综合久久| 亚洲成av人影院| 精品国产精品网麻豆系列 | 五月婷婷久久综合| 精品美女在线观看| av资源站一区| 老司机一区二区| 亚洲视频一区在线观看| 欧美成人午夜电影| 91国产丝袜在线播放| 精品一区二区国语对白| 亚洲乱码日产精品bd| 欧美成人在线直播| 在线视频一区二区三区| 国产一区欧美日韩| 亚洲成人一区在线| 国产精品的网站| 欧美大片免费久久精品三p| 91色在线porny| 久久国产欧美日韩精品| 一区二区三区在线免费| 国产亚洲精久久久久久| 91精品国产欧美日韩| 91女人视频在线观看| 国产一区二区三区精品欧美日韩一区二区三区 | 蜜桃一区二区三区在线观看| 国产精品伦理一区二区| 精品国产麻豆免费人成网站| 欧美视频精品在线| 99精品在线观看视频| 国产一区二区在线视频| 视频一区在线视频| 亚洲一级二级在线| 亚洲日本欧美天堂| 国产精品天天摸av网| 久久亚洲精华国产精华液| 制服丝袜亚洲网站| 欧美亚洲尤物久久| 色先锋aa成人| 91视频在线看| 一本色道久久综合精品竹菊| 成人三级伦理片| 国产成人高清在线| 国产高清精品网站| 国产精品亚洲第一区在线暖暖韩国| 美女免费视频一区二区| 日韩**一区毛片| 日本成人中文字幕| 日韩在线一二三区| 日韩经典一区二区| 日韩高清一区在线| 日本欧美在线看| 蜜臀久久99精品久久久画质超高清| 图片区小说区区亚洲影院| 亚洲大型综合色站| 天堂成人免费av电影一区| 日韩中文字幕1| 美国毛片一区二区| 九九热在线视频观看这里只有精品| 久久精品噜噜噜成人av农村| 久久99久久99| 国产精品影音先锋| 成人激情免费网站| 91丨porny丨首页| 欧美三级视频在线观看| 91精品在线免费| 精品成人一区二区三区四区| 久久精品欧美日韩精品| 国产精品毛片高清在线完整版| 中文字幕在线视频一区| 亚洲男同性恋视频| 五月天一区二区三区| 蜜桃一区二区三区在线| 高清在线成人网| 色综合 综合色| 666欧美在线视频| 久久人人97超碰com| 亚洲视频一区二区在线| 视频一区视频二区在线观看| 激情五月播播久久久精品| 成人免费精品视频| 欧美日韩中文字幕一区| 欧美tk丨vk视频| 国产精品国产三级国产专播品爱网 | 在线看日本不卡| 日韩午夜精品视频| 中文字幕欧美激情| 亚洲1区2区3区4区| 国产成人午夜高潮毛片| 日本高清视频一区二区| 精品蜜桃在线看| 亚洲免费观看高清完整版在线 | 欧美国产精品劲爆| 亚洲亚洲精品在线观看| 国内不卡的二区三区中文字幕| 成人禁用看黄a在线| 欧美一区二区三区视频免费 | 亚洲日本va午夜在线影院| 日韩在线a电影| 99这里只有精品| 日韩免费视频线观看| 亚洲精品视频在线| 国产精品一区二区x88av| 欧美亚洲国产bt| 欧美国产一区二区| 日本成人在线视频网站| 色婷婷一区二区三区四区| 久久婷婷国产综合精品青草| 亚洲成人高清在线| 成人综合婷婷国产精品久久蜜臀| 3d成人h动漫网站入口| 亚洲欧美一区二区三区国产精品| 精品一区二区三区影院在线午夜| 91官网在线观看| 国产精品免费免费| 国产综合久久久久久鬼色 | 日韩av中文在线观看| 9色porny自拍视频一区二区| 久久亚洲精品小早川怜子| 天天综合网天天综合色| 91婷婷韩国欧美一区二区| 国产网红主播福利一区二区| 亚洲午夜在线视频| 99国产精品久久久久久久久久 | 欧美日韩和欧美的一区二区| 亚洲天堂av一区| 国产91综合网| 久久美女艺术照精彩视频福利播放| 日本中文字幕一区| 欧美色图12p| 亚洲欧美国产77777| av激情综合网| 亚洲欧洲日本在线| 不卡在线视频中文字幕| 久久老女人爱爱| 国产精品一区二区无线| 久久综合久久鬼色中文字| 麻豆国产精品视频| 日韩欧美你懂的| 理论片日本一区| 2023国产一二三区日本精品2022| 青青草91视频| 精品日产卡一卡二卡麻豆| 美女国产一区二区| 亚洲精品一区二区三区精华液| 久久精品国产第一区二区三区| 日韩精品一区二区三区四区 | 亚洲不卡av一区二区三区| 欧美日韩在线免费视频| 偷偷要91色婷婷| 欧美一区二区三区在线观看视频 | 黄色资源网久久资源365| 精品欧美黑人一区二区三区| 韩国女主播一区二区三区| wwwwww.欧美系列| 丁香一区二区三区| 亚洲欧美日韩国产另类专区| 91国偷自产一区二区开放时间 | 91麻豆精品在线观看| 亚洲亚洲精品在线观看| 91精品国产福利在线观看 | 午夜久久久久久久久| 91精品国产丝袜白色高跟鞋| 久久99久久精品欧美| 久久精品人人爽人人爽| 一本色道a无线码一区v| 亚洲成av人片一区二区| 日韩欧美国产一区二区在线播放| 国产一区视频导航| 亚洲激情成人在线| 91精品国产免费| youjizz国产精品| 性欧美大战久久久久久久久| 欧美精品一区男女天堂|