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

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

?? os_sem.c

?? 非常經典的8051F040代碼
?? 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一区二区三区免费野_久草精品视频
国产精品久久久久久久久免费桃花| 国产盗摄一区二区| 国产精品久久久久久久久快鸭| 2024国产精品| 久久久综合视频| 久久综合99re88久久爱| 久久久久一区二区三区四区| xnxx国产精品| 亚洲国产精品二十页| 中文字幕一区二| 一区二区三区在线视频免费观看| 亚洲卡通欧美制服中文| 一区二区三区**美女毛片| 亚洲第一主播视频| 美腿丝袜在线亚洲一区| 国产麻豆精品一区二区| 不卡高清视频专区| 欧美在线观看视频在线| 91麻豆精品国产无毒不卡在线观看 | 国产亚洲一区二区三区在线观看| 久久午夜电影网| 成人欧美一区二区三区1314| 一区二区三区91| 日本视频免费一区| 福利一区二区在线观看| 日本韩国精品在线| 欧美一区二区三区四区久久 | 国产精一品亚洲二区在线视频| 麻豆freexxxx性91精品| 成人网男人的天堂| 欧美日韩亚洲国产综合| 国产人伦精品一区二区| 亚洲午夜精品在线| 国产精品一二三| 欧美亚洲图片小说| 久久青草国产手机看片福利盒子 | 国产欧美一区二区精品仙草咪| 国产亚洲一区二区三区四区| 一区二区三区在线影院| 国产一区免费电影| 欧美亚男人的天堂| 中文字幕欧美日韩一区| 亚洲午夜一区二区| 成人一区二区三区中文字幕| 欧美高清你懂得| 亚洲欧美一区二区在线观看| 久久99精品久久只有精品| 99riav一区二区三区| 精品国精品国产| 婷婷夜色潮精品综合在线| 久久精品国内一区二区三区| 色综合咪咪久久| 国产精品私人自拍| 久久99久久99| 欧美精品色一区二区三区| 国产精品色婷婷久久58| 国产主播一区二区三区| 91精品国产欧美一区二区18 | 男男视频亚洲欧美| 日本韩国欧美一区二区三区| 国产精品对白交换视频| 国产成人日日夜夜| 欧美v亚洲v综合ⅴ国产v| 三级精品在线观看| 在线观看日韩一区| 最近中文字幕一区二区三区| 国产91丝袜在线播放九色| 日韩欧美一级二级三级久久久| 亚洲香蕉伊在人在线观| 色婷婷av一区二区三区软件| 亚洲欧洲精品天堂一级| 国产成人精品免费在线| 日本一区二区三区久久久久久久久不 | 一色桃子久久精品亚洲| 成人午夜又粗又硬又大| 亚洲国产精华液网站w| 国产91在线|亚洲| 国产精品免费看片| heyzo一本久久综合| 日韩一区在线免费观看| 91麻豆国产福利精品| 亚洲三级在线看| 欧美专区日韩专区| 亚洲二区在线观看| 欧美美女激情18p| 免费人成黄页网站在线一区二区| 91精品在线一区二区| 麻豆精品在线看| 久久免费午夜影院| 岛国精品在线播放| 一区二区三区中文字幕电影 | 久久国产人妖系列| 精品国产污网站| 国产精品一二三区在线| 国产精品不卡在线观看| 欧美午夜在线观看| 全部av―极品视觉盛宴亚洲| 日韩欧美成人一区二区| 粉嫩久久99精品久久久久久夜| 国产精品高潮呻吟| 91超碰这里只有精品国产| 狠狠色综合播放一区二区| 国产精品婷婷午夜在线观看| 欧美日韩一区二区三区不卡| 久久97超碰色| 亚洲人123区| 日韩免费观看2025年上映的电影| 国产激情视频一区二区在线观看| 亚洲天堂精品视频| 欧美一区二区三区四区五区| 成人国产亚洲欧美成人综合网| 亚洲一区二区在线观看视频| 精品福利在线导航| 91国偷自产一区二区使用方法| 激情五月婷婷综合| 亚洲韩国精品一区| 亚洲国产经典视频| 日韩女优电影在线观看| 色婷婷狠狠综合| 国产成人精品影院| 日本亚洲天堂网| 一区二区三区精品在线| 亚洲人午夜精品天堂一二香蕉| 欧美群妇大交群的观看方式| 成人午夜在线播放| 激情文学综合网| 日韩成人精品在线观看| 亚洲欧美日韩久久精品| 国产女同互慰高潮91漫画| 欧美精品在线观看播放| gogo大胆日本视频一区| 国产成人精品午夜视频免费| 蜜桃视频一区二区三区在线观看| 有码一区二区三区| 国产精品久久久久毛片软件| 欧美第一区第二区| 欧美精品123区| 欧美视频自拍偷拍| 色国产精品一区在线观看| 成人18精品视频| 国产成人免费视频网站| 国产又黄又大久久| 狠狠狠色丁香婷婷综合激情| 免费人成精品欧美精品 | 欧美日韩国产美女| 色综合视频在线观看| 国产69精品一区二区亚洲孕妇| 久久99精品网久久| 精品一区二区三区av| 久久99国产精品免费| 美腿丝袜亚洲色图| 麻豆免费看一区二区三区| 日韩精品成人一区二区三区| 日日夜夜免费精品视频| 日韩精品91亚洲二区在线观看| 日韩精品免费视频人成| 日韩成人免费在线| 精品一区二区三区免费播放| 精彩视频一区二区| 国产乱理伦片在线观看夜一区 | 成人免费黄色在线| 成人午夜av影视| 99久久精品国产麻豆演员表| 99精品视频一区二区三区| 91网上在线视频| 欧美三日本三级三级在线播放| 91精品国产日韩91久久久久久| 日韩视频免费观看高清完整版在线观看 | 亚洲主播在线观看| 午夜精品一区二区三区电影天堂| 日韩激情视频网站| 国产在线国偷精品免费看| 成人动漫在线一区| 91福利国产成人精品照片| 在线综合视频播放| 国产亚洲一区二区在线观看| 国产精品免费看片| 天天色图综合网| 国产激情91久久精品导航 | 日韩国产欧美在线观看| 免费成人美女在线观看.| 国产成人综合网| 在线日韩av片| www欧美成人18+| 综合在线观看色| 蜜桃av一区二区| 成人av电影免费观看| 777亚洲妇女| 国产精品视频你懂的| 香港成人在线视频| 国产激情偷乱视频一区二区三区| 色94色欧美sute亚洲13| 26uuu精品一区二区| 一区二区三区免费| 国产精品一区专区| 欧美日韩aaaaa| 综合久久一区二区三区| 精品中文av资源站在线观看| 色呦呦国产精品| 久久精品一二三|