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

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

?? os_sem.c

?? uc-os
?? 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麻豆福利精品推荐| 99精品视频在线观看| 欧美色男人天堂| 久久精品一级爱片| 亚洲乱码日产精品bd | 日韩高清不卡一区| 成人黄色在线网站| 欧美一区二区免费视频| 亚洲视频每日更新| 成人免费观看视频| 日韩精品一区二区三区三区免费| 国产精品视频免费| 国产真实乱偷精品视频免| 色综合久久久久久久久| 国产日韩影视精品| 国产综合一区二区| 日韩一级高清毛片| 欧美成人综合网站| 久久成人久久爱| 欧美肥妇毛茸茸| 天天免费综合色| 日韩一区二区精品在线观看| 国产精品国产精品国产专区不蜜 | 欧美在线观看禁18| 一区二区在线观看视频在线观看| www.欧美日韩| 亚洲男人天堂av| 一本大道久久精品懂色aⅴ| 国产精品美女一区二区三区| 99免费精品在线| 一区二区三区在线视频观看58| 国产iv一区二区三区| 一区二区中文字幕在线| 成人白浆超碰人人人人| 亚洲午夜免费视频| 久久嫩草精品久久久久| 91免费看`日韩一区二区| 亚洲永久精品大片| 精品福利一二区| 91麻豆成人久久精品二区三区| 亚洲图片欧美综合| 精品久久久久99| 欧美日韩日本视频| 激情综合网av| 视频一区在线播放| 中文字幕成人av| 欧美sm极限捆绑bd| 91黄色免费版| 大桥未久av一区二区三区中文| 五月天激情综合网| 亚洲免费在线播放| 2024国产精品| 欧美一卡在线观看| 在线观看国产一区二区| 99re这里只有精品首页| 激情综合亚洲精品| 免费一级欧美片在线观看| 亚洲色图都市小说| 国产精品欧美一区喷水| 欧美国产日韩精品免费观看| 亚洲国产精品ⅴa在线观看| 精品国一区二区三区| 精品国产污污免费网站入口| 日韩一区二区三区四区| 日韩丝袜美女视频| 国产女人18水真多18精品一级做| 国产欧美综合色| 18成人在线观看| 亚洲黄色小视频| 麻豆精品蜜桃视频网站| 国产成人亚洲综合a∨猫咪| 国产黄色成人av| 欧美色大人视频| 欧美mv日韩mv国产| 国产精品国产三级国产a| 亚洲自拍偷拍综合| 久久电影网电视剧免费观看| 国产在线视频一区二区三区| 91一区二区在线观看| 欧美一级国产精品| 中文字幕乱码一区二区免费| 日韩国产在线一| 一本色道久久综合亚洲aⅴ蜜桃| 欧美日韩aaaaa| 亚洲美女区一区| 久久99深爱久久99精品| 一本大道久久a久久精二百 | 91麻豆国产福利在线观看| 欧美色视频一区| 亚洲精品久久久蜜桃| 国产麻豆成人精品| 欧美成人免费网站| 亚洲高清免费观看高清完整版在线观看| 蜜桃av一区二区在线观看| 色欧美88888久久久久久影院| 欧美国产欧美综合| 国产91精品免费| 久久久久99精品一区| 久久99在线观看| 欧美成人女星排名| 国产一区二区中文字幕| 久久人人爽爽爽人久久久| 久久99热99| 国产日韩欧美精品电影三级在线| 免费人成网站在线观看欧美高清| 欧美男人的天堂一二区| 日韩电影网1区2区| 亚洲精品在线免费播放| 成人精品亚洲人成在线| 国产精品国产三级国产有无不卡| av电影天堂一区二区在线观看| 国产精品每日更新在线播放网址| 韩国成人精品a∨在线观看| 精品国产一区二区三区久久久蜜月| 欧美精品亚洲二区| 秋霞av亚洲一区二区三| 亚洲一区二区三区在线| 亚洲视频在线一区二区| 中文字幕中文字幕一区二区| 久久午夜电影网| 日本一区二区三区电影| 欧美欧美欧美欧美| 成人激情免费电影网址| 婷婷国产在线综合| 国产精品久久久久桃色tv| 91精品在线观看入口| 91久久免费观看| 国产成人aaaa| 日产国产欧美视频一区精品| 久久久久国产精品麻豆| 欧美福利电影网| 欧美日韩的一区二区| 不卡的av电影| 成人性生交大片免费看视频在线| 日韩高清中文字幕一区| 亚洲成va人在线观看| 亚洲最大成人综合| 亚洲精品五月天| 亚洲国产色一区| 亚洲国产综合在线| 亚洲综合视频在线| 青青草精品视频| 老司机精品视频线观看86| 国产麻豆精品95视频| 色成年激情久久综合| 精品福利av导航| 国产精品久久久久久福利一牛影视| 中文字幕av不卡| 秋霞成人午夜伦在线观看| 国产999精品久久久久久绿帽| 99视频一区二区| 5858s免费视频成人| 中文字幕欧美区| 国产综合一区二区| 欧美日韩不卡一区| 亚洲日本在线a| 高清国产一区二区三区| 欧美日韩电影在线播放| 一区二区三区 在线观看视频| 国产综合一区二区| 精品视频一区二区三区免费| 国产欧美日韩中文久久| 黄网站免费久久| 欧美三级日韩三级| 最新不卡av在线| 久久精品国产网站| 日韩欧美国产小视频| 日本欧美在线看| 337p亚洲精品色噜噜噜| 亚洲高清免费一级二级三级| 欧美在线视频不卡| 亚洲成人午夜影院| 777亚洲妇女| 日韩三级伦理片妻子的秘密按摩| 国产乱子伦视频一区二区三区 | 国产成人精品综合在线观看| 国产精品色哟哟网站| caoporm超碰国产精品| 中文字幕在线播放不卡一区| 欧美性受xxxx黑人xyx性爽| 天天操天天干天天综合网| 欧美成人aa大片| 97久久精品人人做人人爽 | 欧美日韩国产片| 麻豆国产欧美日韩综合精品二区| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品一二三四| 天天av天天翘天天综合网| 久久婷婷一区二区三区| 欧美在线观看一区二区| 国精品**一区二区三区在线蜜桃| 国产精品初高中害羞小美女文| 欧美日韩国产在线观看| 色先锋资源久久综合| 国产麻豆午夜三级精品| 免费日本视频一区| 午夜成人免费电影|