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

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

?? os_sem.c

?? ucos系統
?? 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) reentrant
{
    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) reentrant
{
    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) reentrant
{
    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) reentrant
{
    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 *ppdata) reentrant
{
    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);
    }
    ppdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &ppdata->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    ppdata->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一区二区三区免费野_久草精品视频
国产精品白丝jk白祙喷水网站 | 国产在线看一区| 丰满少妇久久久久久久| 欧美亚洲国产一卡| 日本一区二区免费在线| 天天亚洲美女在线视频| 成人av在线电影| 欧美mv和日韩mv国产网站| 亚洲国产美国国产综合一区二区| 国产不卡在线视频| 日韩欧美国产不卡| 亚洲午夜久久久久久久久久久| 粉嫩aⅴ一区二区三区四区五区| 日韩一区二区三区视频在线观看 | aaa欧美大片| 久久久国产午夜精品| 蜜桃传媒麻豆第一区在线观看| 91成人网在线| 亚洲人成在线播放网站岛国| 国产精品影视在线| 久久这里只有精品首页| 六月丁香综合在线视频| 91精品国产综合久久蜜臀| 亚洲综合激情另类小说区| av中文字幕不卡| 国产精品久久久久精k8| 国产成人av一区二区| 久久青草国产手机看片福利盒子| 麻豆精品视频在线观看免费| 91精品国产入口| 午夜欧美大尺度福利影院在线看| 色婷婷av一区| 亚洲精品国产高清久久伦理二区| 97久久超碰国产精品电影| 中文字幕一区日韩精品欧美| 成人综合在线视频| 中文字幕av不卡| 99精品一区二区三区| 亚洲视频在线观看三级| 91日韩精品一区| 亚洲午夜一区二区| 欧美高清一级片在线| 日韩国产成人精品| 欧美成人女星排名| 国产精品 日产精品 欧美精品| 国产网红主播福利一区二区| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 成人av资源站| 亚洲一区二区视频| 91麻豆精品国产91久久久久久久久 | 91精品午夜视频| 精品一区二区三区的国产在线播放| 精品福利一二区| 成人av网站免费观看| 亚洲麻豆国产自偷在线| 欧美日韩国产小视频在线观看| 日韩二区在线观看| 久久精品一区二区三区不卡牛牛| av午夜精品一区二区三区| 一二三区精品福利视频| 91精品国模一区二区三区| 国产在线精品一区二区| 亚洲欧美日本在线| 欧美一级久久久久久久大片| 国产综合久久久久久鬼色| 综合色天天鬼久久鬼色| 欧美伦理视频网站| 成人综合婷婷国产精品久久| 亚洲精品乱码久久久久久久久| 欧美一区二区视频在线观看2020| 高清在线观看日韩| 五月天激情综合| 亚洲国产激情av| 欧美一区二区视频观看视频| 成人a免费在线看| 久久国产日韩欧美精品| 亚洲美女免费在线| 国产喂奶挤奶一区二区三区| 欧美日韩国产一二三| heyzo一本久久综合| 麻豆一区二区99久久久久| 中文字幕日韩一区| 精品国偷自产国产一区| 欧美午夜片在线看| av电影一区二区| 国产一区二区三区精品欧美日韩一区二区三区| 亚洲视频一二三| 中文一区二区完整视频在线观看 | 337p日本欧洲亚洲大胆色噜噜| 色婷婷精品大视频在线蜜桃视频| 国产盗摄女厕一区二区三区| 日韩电影在线一区二区| 亚洲国产精品久久久男人的天堂| 国产夜色精品一区二区av| 欧美一区二区三区免费大片| 在线观看三级视频欧美| 色综合亚洲欧洲| 国产黄色91视频| 婷婷综合另类小说色区| 亚洲色图清纯唯美| 久久精品视频免费| 欧美mv和日韩mv的网站| 欧美一级专区免费大片| 欧美日韩精品一区二区| 欧美伊人久久大香线蕉综合69| 99精品视频在线免费观看| 成人激情校园春色| 国产精品中文欧美| 国产福利一区二区三区在线视频| 精品一区二区三区在线播放| 伦理电影国产精品| 久久99久久久欧美国产| 麻豆精品视频在线观看视频| 另类综合日韩欧美亚洲| 麻豆国产91在线播放| 蜜臀精品一区二区三区在线观看 | 国产精品系列在线观看| 国产精品18久久久久| 国产一区二区三区在线观看免费| 久久国产剧场电影| 久久精品国产99国产精品| 韩国三级在线一区| 国产乱码一区二区三区| 国产成人精品免费看| 成人黄色网址在线观看| 91碰在线视频| 欧美这里有精品| 日韩视频免费观看高清完整版在线观看| 在线成人av网站| 精品精品国产高清一毛片一天堂| 久久免费看少妇高潮| 中文字幕中文字幕在线一区| 一区二区三区日韩在线观看| 无码av中文一区二区三区桃花岛| 日本伊人色综合网| 国产麻豆精品在线观看| 波多野结衣亚洲| 精品视频资源站| 欧美mv日韩mv国产| 亚洲欧洲在线观看av| 亚洲电影在线免费观看| 美女尤物国产一区| 不卡一卡二卡三乱码免费网站| 91蜜桃婷婷狠狠久久综合9色| 欧美日韩国产另类一区| 精品国产电影一区二区| 国产精品久久网站| 午夜激情综合网| 国产精品亚洲人在线观看| 一本久久综合亚洲鲁鲁五月天| 欧美日产在线观看| 国产欧美一区在线| 亚洲综合在线观看视频| 激情综合五月婷婷| 欧美自拍偷拍午夜视频| 久久免费精品国产久精品久久久久| 一区二区三区四区高清精品免费观看| 日本va欧美va精品发布| 波多野结衣视频一区| 日韩三级在线观看| 亚洲综合一二三区| 成人午夜视频在线| 日韩欧美国产综合一区| 亚洲视频1区2区| 国产一区二区女| 9191国产精品| 亚洲图片欧美激情| 国产精品123区| 日韩欧美国产综合| 亚洲成人综合网站| 91色.com| 国产精品福利在线播放| 韩国三级在线一区| 日韩一区二区三区高清免费看看| 亚洲色图.com| 国产成人在线观看| 精品日韩成人av| 奇米影视一区二区三区| 欧美亚洲自拍偷拍| 中文字幕日韩精品一区| 风间由美性色一区二区三区| 日韩欧美国产一区二区三区 | 一区二区三区四区视频精品免费 | 国内一区二区在线| 欧美剧情片在线观看| 亚洲午夜在线电影| 一本色道久久综合亚洲aⅴ蜜桃| 中文欧美字幕免费| 国产成人精品一区二| 精品久久国产老人久久综合| 热久久久久久久| 欧美巨大另类极品videosbest | 自拍偷拍亚洲欧美日韩| 国产精品一区不卡| 久久天堂av综合合色蜜桃网| 极品少妇一区二区| 久久久激情视频| 国产91在线观看丝袜| 国产女主播一区| 成人avav影音|