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

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

?? os_sem.c

?? S3C44B0開發(fā)板的板級測試代碼
?? 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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久婷婷色综合| 国产乱码精品一区二区三区五月婷| 成人激情视频网站| 久久精品亚洲乱码伦伦中文| 成人app在线| 悠悠色在线精品| 欧美影院一区二区| 视频精品一区二区| 久久婷婷国产综合精品青草| 国产乱码精品一区二区三区五月婷| 中文文精品字幕一区二区| 一本一道久久a久久精品| 国产精品亚洲成人| 国产精品大尺度| 欧洲国内综合视频| 免费精品视频在线| 国产婷婷色一区二区三区| 97久久人人超碰| 天天综合色天天| 久久久久99精品国产片| 北条麻妃一区二区三区| 亚洲高清免费观看| 久久久亚洲精品石原莉奈| 99国产精品99久久久久久| 日韩影院免费视频| 国产精品欧美一区喷水| 欧美日韩精品综合在线| 国产乱码字幕精品高清av| 亚洲综合色婷婷| 亚洲精品一区二区在线观看| 91亚洲精品一区二区乱码| 麻豆一区二区99久久久久| 综合分类小说区另类春色亚洲小说欧美| 亚洲女人小视频在线观看| 777a∨成人精品桃花网| 成人av在线一区二区| 免费观看久久久4p| 一区二区三区91| 久久久蜜桃精品| 欧美日韩高清一区| 成人动漫一区二区在线| 蜜桃久久av一区| 亚洲在线一区二区三区| 国产精品毛片a∨一区二区三区| 91麻豆精品国产自产在线观看一区| 国产99久久精品| 看国产成人h片视频| 亚洲乱码国产乱码精品精小说| 久久久无码精品亚洲日韩按摩| 欧美午夜影院一区| 99精品国产99久久久久久白柏| 久久精品国产精品青草| 亚洲国产一区二区三区| 亚洲人精品午夜| 国产欧美日韩久久| 精品国产3级a| 日韩欧美不卡在线观看视频| 欧美日韩国产一二三| 色菇凉天天综合网| av成人老司机| 99久久免费视频.com| 国产成人av电影在线播放| 国精产品一区一区三区mba桃花| 五月婷婷另类国产| 亚洲国产日韩在线一区模特| 亚洲精品免费在线观看| 亚洲欧洲av在线| 国产精品第一页第二页第三页| 国产午夜精品福利| 国产丝袜美腿一区二区三区| 国产亚洲精品免费| 国产清纯在线一区二区www| 日韩视频一区二区在线观看| 日韩一级精品视频在线观看| 欧美一区二区三区免费视频 | 一区二区三区精品视频| 国产精品精品国产色婷婷| 国产一区二区视频在线| 看电影不卡的网站| 国产资源在线一区| 国产盗摄一区二区三区| 国产91精品入口| 不卡欧美aaaaa| 色综合一个色综合| 色诱亚洲精品久久久久久| 在线国产电影不卡| 欧美高清你懂得| 欧美成人精品3d动漫h| 日韩精品在线一区二区| 久久久久97国产精华液好用吗| 久久久久国色av免费看影院| 国产精品视频yy9299一区| 国产精品卡一卡二| 亚洲综合在线观看视频| 午夜欧美2019年伦理| 精品一区二区三区av| 国产99久久久精品| 色综合中文字幕国产| 日本高清不卡在线观看| 91麻豆精品国产91久久久久久| 日韩欧美国产高清| 国产蜜臀97一区二区三区| 一区二区国产盗摄色噜噜| 日韩和欧美一区二区| 国产麻豆视频一区二区| 色一区在线观看| 777午夜精品免费视频| 久久久国际精品| 夜夜精品视频一区二区| 激情综合色综合久久综合| 波多野结衣中文字幕一区二区三区| 欧美亚洲综合在线| 精品第一国产综合精品aⅴ| 综合在线观看色| 五月天亚洲精品| 国产91丝袜在线播放九色| 欧美色视频在线| 久久久久久久久蜜桃| 亚洲电影第三页| 风流少妇一区二区| 欧美丰满美乳xxx高潮www| 国产精品午夜春色av| 香港成人在线视频| 白白色亚洲国产精品| 日韩欧美国产1| 一区二区三区视频在线看| 国产剧情一区二区三区| 欧美调教femdomvk| 国产精品日韩成人| 青青青爽久久午夜综合久久午夜| av在线免费不卡| 精品久久久久久久人人人人传媒 | 色香蕉成人二区免费| 26uuu欧美| 日韩精品1区2区3区| 91美女视频网站| 欧美激情综合网| 精品一区二区三区蜜桃| 欧美日韩性生活| 亚洲精品国久久99热| 国产不卡在线播放| 日韩女同互慰一区二区| av亚洲精华国产精华| 久久久久88色偷偷免费| 毛片基地黄久久久久久天堂| 欧美日韩www| 亚洲精品国产无天堂网2021| 成人99免费视频| 久久视频一区二区| 精品综合久久久久久8888| 欧美日韩精品一区二区三区四区| 最近中文字幕一区二区三区| 国产精品1区2区3区在线观看| 日韩欧美国产一区二区在线播放| 亚洲v精品v日韩v欧美v专区| 在线观看日韩高清av| 亚洲少妇屁股交4| 972aa.com艺术欧美| 国产精品久久久久久久久搜平片| 国产高清不卡一区二区| xvideos.蜜桃一区二区| 国产一区二区三区电影在线观看| 欧美成人性战久久| 精品一区二区三区影院在线午夜| 在线不卡中文字幕播放| 丝袜美腿成人在线| 欧美精品色一区二区三区| 亚洲成av人片在线| 欧美精品tushy高清| 日本欧美在线观看| 欧美猛男男办公室激情| 五月激情综合色| 日韩欧美高清一区| 国内精品伊人久久久久影院对白| 精品三级在线观看| 国产福利一区二区三区视频| 亚洲国产精品av| 99在线精品免费| 亚洲综合色在线| 制服丝袜国产精品| 精彩视频一区二区三区| 久久女同互慰一区二区三区| 粉嫩一区二区三区在线看| 亚洲欧洲av在线| 在线看不卡av| 日本一不卡视频| 久久久久久久网| 99这里只有精品| 丝瓜av网站精品一区二区| 欧美一区二区日韩一区二区| 国产一区二区美女诱惑| 国产精品久久精品日日| 欧美日本视频在线| 精品一区二区免费视频| 国产精品乱人伦| 欧美日韩成人在线一区| 国产一区啦啦啦在线观看| 亚洲欧美韩国综合色| 日韩欧美激情在线| av在线这里只有精品|