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

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

?? os_sem.c

?? 把UCOS2移植到TMS320L2812上
?? 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一区二区三区免费野_久草精品视频
天天综合日日夜夜精品| 久久久一区二区三区捆绑**| av在线不卡免费看| 国产.欧美.日韩| 国产一区二区精品久久91| 日韩精品乱码免费| 日韩激情视频在线观看| 日韩中文欧美在线| 免费看日韩精品| 日韩1区2区3区| 久久www免费人成看片高清| 精品无人码麻豆乱码1区2区 | 久久精品人人做| 国产日韩欧美综合在线| 国产色综合一区| 国产精品久久久久一区二区三区共| 国产精品美女久久福利网站| 亚洲欧美视频在线观看视频| 夜夜精品浪潮av一区二区三区| 亚洲国产精品久久人人爱蜜臀| 亚洲成av人片www| 久久精品999| 福利一区二区在线观看| 色哟哟国产精品免费观看| 欧美日韩小视频| 精品国产亚洲一区二区三区在线观看 | 欧洲在线/亚洲| 欧美一区二区精品在线| 久久久国产一区二区三区四区小说 | 欧美性三三影院| 7777精品伊人久久久大香线蕉经典版下载 | 精品视频在线看| 日韩欧美中文一区| 国产欧美日韩在线看| 亚洲综合在线免费观看| 蜜桃av噜噜一区| 99久久久久久| 日韩久久精品一区| 综合欧美亚洲日本| 美女爽到高潮91| 99久久精品国产一区二区三区| 欧美色图免费看| 国产欧美日韩亚州综合| 亚洲成a人v欧美综合天堂| 国产精品自在在线| 欧美中文字幕不卡| 久久久久久久精| 日韩主播视频在线| 成人涩涩免费视频| 欧美一级电影网站| ...xxx性欧美| 激情综合色播五月| 日本精品一级二级| 久久久亚洲精品一区二区三区| 亚洲第一主播视频| 国产suv一区二区三区88区| 欧美亚洲国产一区二区三区| 久久婷婷国产综合精品青草| 亚洲一区二区在线免费看| 国产精品1区2区| 91 com成人网| 亚洲乱码中文字幕| 国产乱码精品一品二品| 欧美一区二区三区色| 亚洲视频免费看| 国产精品亚洲第一| 欧美一级片在线观看| 一区二区三区不卡视频在线观看| 国产精品综合视频| 精品精品国产高清a毛片牛牛| 亚洲一区二区三区四区中文字幕| 成人永久aaa| 久久综合成人精品亚洲另类欧美 | 欧美卡1卡2卡| 亚洲人成伊人成综合网小说| 国产成人综合亚洲91猫咪| 日韩一级片在线观看| 亚洲国产精品久久一线不卡| 成人av在线资源网| 91啦中文在线观看| 中文字幕精品综合| 国产乱码精品一区二区三| 精品日韩一区二区三区免费视频| 五月天激情小说综合| 在线观看av一区二区| 亚洲欧美电影一区二区| 波多野结衣中文字幕一区二区三区 | 国产女主播视频一区二区| 麻豆精品国产传媒mv男同| 91精品国产综合久久婷婷香蕉| 亚洲图片欧美色图| 色8久久人人97超碰香蕉987| 亚洲美女免费在线| 91美女在线观看| 亚洲欧美日韩国产综合| 91美女片黄在线| 亚洲视频 欧洲视频| 99久久久精品| 亚洲少妇30p| 色综合天天性综合| 亚洲色图在线播放| 91视频免费播放| 亚洲精品视频观看| 欧美亚洲精品一区| 爽爽淫人综合网网站| 6080yy午夜一二三区久久| 偷窥少妇高潮呻吟av久久免费| 欧美日韩国产免费一区二区 | 免费观看一级欧美片| 91精品国产综合久久精品| 日韩av不卡一区二区| 精品国产污污免费网站入口 | 26uuu精品一区二区三区四区在线| 久久电影国产免费久久电影| 久久久久久久久99精品| 成人精品国产一区二区4080| 亚洲丝袜美腿综合| 91久久精品日日躁夜夜躁欧美| 亚洲成人1区2区| 欧美电影免费提供在线观看| 国产精品资源在线| 亚洲欧洲日韩综合一区二区| 在线免费一区三区| 日本最新不卡在线| 久久久久久**毛片大全| 99久久精品情趣| 亚洲aⅴ怡春院| 精品国产99国产精品| 成人久久18免费网站麻豆| 亚洲精品成人精品456| 91精品国产综合久久精品麻豆| 精久久久久久久久久久| 国产精品美女www爽爽爽| 欧美四级电影在线观看| 久久成人免费网| 亚洲男人天堂av网| 欧美一区二区不卡视频| 国v精品久久久网| 亚洲风情在线资源站| 精品国内片67194| 一本色道久久综合亚洲aⅴ蜜桃| 无码av中文一区二区三区桃花岛| 精品成人免费观看| 色综合色综合色综合色综合色综合 | 久久久久国产成人精品亚洲午夜| 99久久伊人精品| 人人精品人人爱| 一区免费观看视频| 欧美成人一区二区三区片免费| 99久久777色| 精品午夜久久福利影院| 亚洲午夜在线观看视频在线| 久久久亚洲精品石原莉奈| 色综合久久中文字幕| 国产资源在线一区| 亚洲小说欧美激情另类| 亚洲国产精品激情在线观看| 欧美日韩精品电影| 99久精品国产| 黑人巨大精品欧美黑白配亚洲| 夜色激情一区二区| 中文字幕+乱码+中文字幕一区| 欧美一区二区三区不卡| 色香蕉成人二区免费| 国产精品资源在线看| 日本最新不卡在线| 一区二区三区四区不卡在线 | 亚洲国产精品综合小说图片区| 久久精品夜色噜噜亚洲a∨| 欧美日韩一区视频| 不卡的av中国片| 国产乱码精品一区二区三区av | 亚洲成人福利片| 亚洲视频香蕉人妖| 国产欧美一区二区在线| 日韩欧美美女一区二区三区| 欧美午夜在线观看| 高清不卡一区二区在线| 美国十次了思思久久精品导航| 一级日本不卡的影视| 国产精品沙发午睡系列990531| 精品美女在线观看| 91精品国产欧美日韩| 在线观看日韩精品| 91麻豆福利精品推荐| proumb性欧美在线观看| 国产精品一区三区| 国产在线精品一区二区夜色| 午夜亚洲福利老司机| 依依成人综合视频| 亚洲色图20p| 亚洲免费视频成人| 亚洲欧洲av另类| 中文字幕va一区二区三区| 欧美激情综合五月色丁香小说| 久久综合五月天婷婷伊人| 精品久久久三级丝袜| 日韩欧美一级二级三级久久久| 91 com成人网| 日韩三级电影网址|