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

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

?? os_sem.c

?? ucos在三星ARMs3c44b0上運(yùn)行源碼.
?? 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一区二区三区免费野_久草精品视频
在线视频中文字幕一区二区| 一区二区欧美国产| 日韩情涩欧美日韩视频| 欧美综合天天夜夜久久| 日韩视频免费观看高清完整版在线观看 | 成人国产精品免费观看动漫| 99久久综合国产精品| 欧美高清dvd| 亚洲日本va午夜在线影院| 男人的j进女人的j一区| 99久久综合国产精品| 久久久国产精品麻豆| 日精品一区二区三区| 91美女精品福利| 一本久道久久综合中文字幕 | 成人久久久精品乱码一区二区三区| 精品一二三四在线| 久久av老司机精品网站导航| 欧美日韩在线播放三区四区| 国产精品久久久久久久久果冻传媒| 美国精品在线观看| 欧美日免费三级在线| 夜色激情一区二区| 91玉足脚交白嫩脚丫在线播放| 中文字幕不卡的av| 国产精品18久久久久久久久久久久 | 91在线视频官网| 久久精品欧美一区二区三区麻豆| 日本成人中文字幕在线视频| 在线成人午夜影院| 日韩高清一区在线| 欧美精品日日鲁夜夜添| 亚洲午夜一区二区| 欧美日韩国产一级二级| 亚洲h动漫在线| 欧美夫妻性生活| 美日韩黄色大片| 欧美mv日韩mv国产网站| 韩国三级在线一区| 亚洲精品一区二区三区精华液| 免费高清在线一区| 欧美va日韩va| 国产成a人亚洲精| 国产精品乱码久久久久久| av午夜一区麻豆| 亚洲免费观看高清完整| 91福利社在线观看| 日韩成人午夜电影| 日韩免费成人网| 岛国精品一区二区| 亚洲久草在线视频| 欧美一区二区三区免费大片| 久久99精品国产.久久久久久| 日韩免费性生活视频播放| 国产不卡在线一区| 亚洲第一成人在线| 精品国产一二三| 成人av在线播放网站| 亚洲精品视频一区二区| 欧美日韩中文一区| 亚洲三级在线免费| 一本大道久久a久久综合| 亚洲18影院在线观看| 日韩精品一区二区三区在线观看| 国产成人免费av在线| 一区二区三区在线高清| 日韩一区二区三区高清免费看看 | 免费人成黄页网站在线一区二区| 久久在线观看免费| 在线亚洲一区二区| 国内偷窥港台综合视频在线播放| 综合久久久久久| 欧美一区二区三区在线视频| 国产精品自拍三区| 亚洲成a人片综合在线| 久久久久国产精品麻豆ai换脸| 色成人在线视频| 狠狠色丁香婷综合久久| 一区二区三区电影在线播| 精品美女在线观看| 欧美撒尿777hd撒尿| 成人精品一区二区三区中文字幕| 亚洲6080在线| 亚洲欧洲国产日韩| 久久五月婷婷丁香社区| 欧美日韩久久一区| 99国产精品视频免费观看| 久久er99热精品一区二区| 亚洲另类春色校园小说| 国产日韩欧美亚洲| 欧美一卡二卡三卡| 欧美三级日韩三级国产三级| 成人精品鲁一区一区二区| 久久99国产精品麻豆| 亚洲成人激情av| 依依成人综合视频| 国产三级久久久| 欧美不卡视频一区| 国产精品剧情在线亚洲| 亚洲精品成人天堂一二三| 精品少妇一区二区三区视频免付费 | 亚洲韩国精品一区| 国产精品亲子伦对白| 欧美精品一区二区久久婷婷| 欧美日韩一区在线| 色婷婷综合在线| 成人h动漫精品一区二区| 国产精品主播直播| 国产麻豆午夜三级精品| 蜜臀a∨国产成人精品| 九色|91porny| 免费久久99精品国产| 午夜欧美2019年伦理| 久久久欧美精品sm网站| 成人激情动漫在线观看| 国产精品一区2区| 亚洲成在线观看| 国产欧美视频一区二区| 欧美日韩一级片网站| 在线视频你懂得一区| 在线视频欧美区| 欧美亚洲图片小说| 欧美日韩在线精品一区二区三区激情| 欧美影视一区二区三区| 在线观看av一区二区| 欧美日韩五月天| 欧美一区二区视频网站| 久久综合资源网| 国产亚洲精品aa午夜观看| 中国av一区二区三区| 国产精品初高中害羞小美女文| |精品福利一区二区三区| 亚洲男人的天堂一区二区| 亚洲综合色视频| 日韩电影一二三区| 韩国三级在线一区| 97久久人人超碰| 欧美日韩免费视频| 26uuu亚洲综合色| 国产精品三级av在线播放| 一区二区视频在线| 日本中文在线一区| 国产精品系列在线播放| 色老综合老女人久久久| 91精品国产91综合久久蜜臀| 久久精品在这里| 亚洲免费色视频| 狠狠色丁香婷婷综合| 色噜噜狠狠色综合中国| 欧美r级在线观看| 亚洲欧美日韩国产综合| 免费观看在线综合色| av在线不卡免费看| 欧美福利一区二区| 国产精品对白交换视频| 肉色丝袜一区二区| 丰满岳乱妇一区二区三区| 91久久免费观看| 久久综合资源网| 亚洲国产精品人人做人人爽| 久久精品国产亚洲aⅴ| 91网上在线视频| 欧美成人aa大片| 亚洲制服丝袜av| 丁香婷婷综合网| 欧美一级一区二区| 综合电影一区二区三区| 激情欧美一区二区| 欧美日韩一区二区三区不卡| 亚洲国产成人在线| 精品在线一区二区| 欧美在线一区二区| 亚洲欧洲美洲综合色网| 久久99国内精品| 欧美日韩高清一区二区三区| 国产精品国产三级国产普通话99 | 日韩欧美你懂的| 亚洲第一久久影院| 91浏览器打开| 中文字幕精品在线不卡| 激情综合五月天| 宅男在线国产精品| 亚洲午夜精品在线| 色诱亚洲精品久久久久久| 日本一二三四高清不卡| 精品一区二区免费看| 欧美精三区欧美精三区| 亚洲自拍偷拍综合| 日本精品一区二区三区四区的功能| 国产欧美日韩不卡| 国产精品白丝jk白祙喷水网站| 欧美精品一区男女天堂| 久久成人精品无人区| 91精品国产综合久久精品| 亚洲成va人在线观看| 欧美午夜精品久久久久久孕妇| 亚洲精品国产精品乱码不99| 一本一道综合狠狠老| 亚洲女同女同女同女同女同69| 91免费看片在线观看|