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

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

?? os_sem.c

?? 在C8051F120內(nèi)移植uCOS-II
?? C
字號(hào):
/*
*********************************************************************************************************
*                                                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
#define OS_SEM_GLOBALS
#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
*********************************************************************************************************
*/
#if OS_Sem_Accept_EN
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                        */
}
#endif

/*$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
*********************************************************************************************************
*/
#if OS_Sem_Create_EN
OS_EVENT *OSSemCreate (INT16U cnt)reentrant
{
    #if OS_CRITICAL_METHOD == 2
	unsigned DTYPE int_ss;
	#endif 

	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);
}
#endif

/*$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
*********************************************************************************************************
*/
#if OS_Sem_Pend_EN
void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)reentrant
{
   	#if OS_CRITICAL_METHOD == 2
	unsigned DTYPE int_ss;
	#endif 

    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;
        }
    }
}
#endif
/*$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
*********************************************************************************************************
*/
#if OS_Sem_Post_EN
INT8U OSSemPost (OS_EVENT *pevent)reentrant
{
    #if OS_CRITICAL_METHOD == 2
	unsigned DTYPE int_ss;
	#endif
	 
	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);
        }
    }
}
#endif
/*
*********************************************************************************************************
*                                          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
*
*              dataptr         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.
*********************************************************************************************************
*/
#if   OS_Sem_Query_EN
INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *dataptr)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);
    }
    dataptr->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
    psrc              = &pevent->OSEventTbl[0];
    pdest             = &dataptr->OSEventTbl[0];
    for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
        *pdest++ = *psrc++;   
    }
    dataptr->OSCnt      = pevent->OSEventCnt;                /* Get semaphore count                      */
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
#endif
#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡一区中文字幕| 日韩国产欧美一区二区三区| 一区二区三区四区五区视频在线观看| 亚洲美女电影在线| 日韩精品一级二级| 国产一区二区女| 91黄色免费看| 精品日韩在线观看| 中文字幕一区二区视频| 亚洲成人自拍网| 国产精品1区2区| 欧美激情资源网| 亚洲激情图片qvod| 水野朝阳av一区二区三区| 亚洲成av人片在线| 国产成人av一区二区| 久久精品综合网| 国产欧美一区二区精品忘忧草| 国产精品私人影院| 日韩成人伦理电影在线观看| 国产综合久久久久影院| 欧美精品久久99久久在免费线| 日韩精品中文字幕一区| 国产精品久久久久久久裸模 | 视频在线在亚洲| 国产精品影视网| 在线电影欧美成精品| 国产精品无人区| 蜜桃精品在线观看| 色婷婷一区二区三区四区| 亚洲精品一区二区三区精华液| 亚洲男人的天堂av| 国产成人啪午夜精品网站男同| 91国产福利在线| 国产农村妇女毛片精品久久麻豆| 亚洲成人激情社区| 91在线无精精品入口| 久久综合999| 午夜伊人狠狠久久| 91色.com| 亚洲国产精品av| 久久99精品久久久久久国产越南| 91高清视频免费看| 国产精品嫩草99a| 久久99国产精品免费| 欧美人xxxx| 亚洲精品午夜久久久| 成人精品视频.| 久久日韩粉嫩一区二区三区| 免费看日韩a级影片| 欧美日韩国产一区二区三区地区| 亚洲三级在线免费观看| 国产传媒一区在线| 精品国产乱码久久久久久久| 亚洲1区2区3区4区| 欧美午夜精品免费| 亚洲精选视频在线| 91在线视频网址| 欧美激情综合在线| 春色校园综合激情亚洲| 日韩午夜精品视频| 免费在线看成人av| 日韩色视频在线观看| 亚洲美女视频一区| 在线播放视频一区| 91国偷自产一区二区使用方法| 亚洲欧美一区二区不卡| 欧洲精品一区二区三区在线观看| 成人av电影在线网| 自拍偷拍亚洲综合| 在线观看成人免费视频| 日本美女一区二区三区| 久久精品这里都是精品| 日韩一区二区不卡| 国产精品免费丝袜| 久久精品国产在热久久| 日韩一区二区三区电影在线观看 | 国产老女人精品毛片久久| 精品国产麻豆免费人成网站| 另类小说图片综合网| 精品久久久久久久人人人人传媒 | 久久伊99综合婷婷久久伊| 久久精品久久99精品久久| 日韩精品一区二区在线观看| 麻豆精品一区二区综合av| 日韩欧美一级二级| 国产一区二区三区高清播放| 国产女主播在线一区二区| 懂色av一区二区三区免费看| 国产精品九色蝌蚪自拍| 色成年激情久久综合| 亚洲一二三四区| 制服.丝袜.亚洲.另类.中文| 奇米精品一区二区三区在线观看 | 美女看a上一区| 精品久久久久久久久久久久包黑料 | 欧美美女一区二区在线观看| 午夜av区久久| 精品91自产拍在线观看一区| 国产成人精品影院| 亚洲综合一二三区| 美女性感视频久久| 香蕉久久一区二区不卡无毒影院 | 亚洲欧洲无码一区二区三区| 欧美一区二区福利在线| 欧美日韩在线一区二区| 色综合网色综合| 91美女片黄在线观看| 成人免费av在线| 国产在线播放一区三区四| 国产真实乱子伦精品视频| 欧美国产综合色视频| 成人av在线播放网站| 一区二区三区精密机械公司| 7777精品伊人久久久大香线蕉完整版 | 五月天激情综合| 精品少妇一区二区三区| 91原创在线视频| 麻豆一区二区三区| 最新中文字幕一区二区三区| 欧美美女视频在线观看| 日韩欧美黄色影院| 97精品久久久午夜一区二区三区 | 欧美在线色视频| 久久se这里有精品| 亚洲精品日产精品乱码不卡| 欧美成人vr18sexvr| 97精品国产97久久久久久久久久久久| 奇米影视7777精品一区二区| 国产精品传媒视频| 日韩精品综合一本久道在线视频| 北条麻妃国产九九精品视频| 日韩vs国产vs欧美| 国产精品大尺度| 精品国产a毛片| 欧美日韩免费一区二区三区视频| 国产成人av资源| 欧美a一区二区| 一区二区三区中文免费| 久久久精品一品道一区| 欧美日韩国产另类不卡| 北条麻妃一区二区三区| 紧缚奴在线一区二区三区| 一区二区三区国产精华| 国产欧美一区二区三区在线看蜜臀| 欧美日韩国产高清一区二区三区 | 91亚洲精品乱码久久久久久蜜桃| 欧美日韩国产影片| 国产人伦精品一区二区| 亚洲主播在线播放| 91网站黄www| 欧美经典一区二区| 国内欧美视频一区二区 | 欧美色精品在线视频| 日韩一区二区三区精品视频| 日本91福利区| 亚洲欧洲综合另类| 久久中文娱乐网| 91精品国产综合久久精品图片 | 国产欧美日韩中文久久| 555www色欧美视频| 日本久久一区二区| 91亚洲国产成人精品一区二三| 国产成人精品1024| 韩国av一区二区三区在线观看| 天使萌一区二区三区免费观看| 亚洲乱码国产乱码精品精小说 | 91亚洲精品久久久蜜桃| 成人av午夜电影| 成人亚洲一区二区一| 激情六月婷婷久久| 国产在线观看一区二区| 精品一区免费av| 美日韩黄色大片| 日本欧美加勒比视频| 肉肉av福利一精品导航| 亚洲午夜激情网站| 亚洲一区二区三区中文字幕在线| 亚洲色图欧美激情| 亚洲视频在线观看一区| 亚洲日本va午夜在线影院| 亚洲欧洲日韩在线| ●精品国产综合乱码久久久久| 亚洲视频每日更新| 亚洲私人影院在线观看| 亚洲精品视频一区二区| 亚洲一区在线免费观看| 一区二区三区不卡在线观看| 亚洲综合色自拍一区| 五月天网站亚洲| 日韩精彩视频在线观看| 麻豆专区一区二区三区四区五区| 久久av资源站| 国产剧情一区二区| 成人av集中营| 欧美专区亚洲专区| 88在线观看91蜜桃国自产| 日韩欧美一区二区视频| 久久久久久久久久电影| 中文字幕中文乱码欧美一区二区|