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

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

?? emos_sem.c

?? emos是一個新的類似于ucos的內核
?? C
字號:
/****************************************************************************
 *
 * (c) Copyright 2001,2008, EMB system, All Rights Reserved.
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF EMB SYSTEM, INC.
 * The copyright notice above does not evidence any actual or intended
 * publication of such source code. 
 *
 *  Subsystem:    EMOS 
 *  File:         emos_sem.c
 *  Author:       zenf zhao
 *  Description:  EMOS sem management file
 *
 ****************************************************************************/
#include "emos_cfg.h"
#include "emos_core.h"

#if EMOS_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
**********************************************************************************************************/

uint16 emosSemAccept (EMOS_EVENT_T *pevent)
{
    uint16 cnt;

    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_SEM) 
    {   /* Validate event block type */
        EMOS_EXIT_CRITICAL();
        return (0);
    }
    
    cnt = pevent->osEventCnt;
    if (cnt > 0) 
    { 
    	/* See if resource is available */
        pevent->osEventCnt--; /* Yes, decrement semaphore and notify caller */
    }
    EMOS_EXIT_CRITICAL();
    return (cnt);  /* Return semaphore count */
}


/*********************************************************************************************************
* 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 (EMOS_EVENT_T) associated with the
*                            created semaphore
*              == (void *)0  if no event control blocks were available
**********************************************************************************************************/
EMOS_EVENT_T *emosSemCreate (uint16 cnt)
{
    EMOS_EVENT_T *pevent;

    EMOS_ENTER_CRITICAL();
    pevent = gEmosEventFreeList;  /* Get next free event control block */
    if (gEmosEventFreeList != (EMOS_EVENT_T *)0)
    {   
    	/* See if pool of free ECB pool was empty   */
        gEmosEventFreeList = (EMOS_EVENT_T *)gEmosEventFreeList->osEventPtr;
    }
    EMOS_EXIT_CRITICAL();
    
    if (pevent != (EMOS_EVENT_T *)0)
    {   /* Get an event control block */
        pevent->osEventType = EMOS_EVENT_TYPE_SEM;
        pevent->osEventCnt  = cnt; /* Set semaphore value */
        emosEventWaitListInit(pevent);
    }
    return (pevent);
}


/*********************************************************************************************************
* 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:
*                            EMOS_NO_ERR  The call was successful and your task owns the resource 
*                                          or, the event you are waiting for occurred.
*                            EMOS_TIMEOUT  The semaphore was not received within the specified 
*                                          timeout.
*                            EMOS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore.
*                            EMOS_ERR_PEND_ISR    If you called this function from an ISR and the result
*                                               would lead to a suspension.
*              Returns    : none
**********************************************************************************************************/
void emosSemPend (EMOS_EVENT_T *pevent, uint16 timeout, uint8 *err)
{
    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_SEM)
    {   /* Validate event block type */
        EMOS_EXIT_CRITICAL();
        *err = EMOS_ERR_EVENT_TYPE;
    }
    
    if (pevent->osEventCnt > 0) 
    {   /* If sem. is positive, resource available ... */
        pevent->osEventCnt--; /* ... decrement semaphore only if positive. */
        EMOS_EXIT_CRITICAL();
        *err = EMOS_NO_ERR;
    } 
    else if (gEmosIntNesting > 0)
    {   /* See if called from ISR ...*/
        EMOS_EXIT_CRITICAL(); /* ... can't PEND from an ISR */
        *err = EMOS_ERR_PEND_ISR;
    } 
    else 
    {                                                /* Otherwise, must wait until event occurs       */
        gEmosTCBCur->osTCBStat |= EMOS_STAT_SEM;    /* Resource not available, pend on semaphore     */
        gEmosTCBCur->osTCBDly = timeout;            /* Store pend timeout in TCB                     */
        emosEventTaskWait(pevent);                  /* Suspend task until event or timeout occurs    */
        EMOS_EXIT_CRITICAL();
        emosSched();                                    /* Find next highest priority task ready         */

        EMOS_ENTER_CRITICAL();
        if (gEmosTCBCur->osTCBStat & EMOS_STAT_SEM) 
        {  
        	/* Must have timed out if still waiting for event*/
            emosEventTo(pevent);
            EMOS_EXIT_CRITICAL();
            *err = EMOS_TIMEOUT;  /* Indicate that didn't get event within TO */
        } 
        else 
        {
            gEmosTCBCur->osTCBEventPtr = (EMOS_EVENT_T *)0;
            EMOS_EXIT_CRITICAL();
            *err = EMOS_NO_ERR;
        }
    }
}

/********************************************************************************************************
* 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    : EMOS_NO_ERR   The call was successful and the semaphore was signaled.
*              EMOS_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().
*              EMOS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore
**********************************************************************************************************/

uint8 emosSemPost (EMOS_EVENT_T *pevent)
{
    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_SEM)
    { 
    	/* Validate event block type */
        EMOS_EXIT_CRITICAL();
        return (EMOS_ERR_EVENT_TYPE);
    }
    if (pevent->osEventGrp) 
    {   /* See if any task waiting for semaphore    */
        emosEventTaskRdy(pevent, (void *)0, EMOS_STAT_SEM);  /* Ready highest prio task waiting on event */
        EMOS_EXIT_CRITICAL();
        emosSched();  /* Find highest priority task ready to run*/
        return (EMOS_NO_ERR);
    } 
    else 
    {
        if (pevent->osEventCnt < 65535) 
        {   /* Make sure semaphore will not overflow*/
            pevent->osEventCnt++; /* Increment semaphore count to register event   */
            EMOS_EXIT_CRITICAL();
            return (EMOS_NO_ERR);
        } 
        else 
        {                                      /* Semaphore value has reached its maximum       */
            EMOS_EXIT_CRITICAL();
            return (EMOS_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    : EMOS_NO_ERR          The call was successful and the message was sent
*              EMOS_ERR_EVENT_TYPE  If you are attempting to obtain data from a non semaphore.
**********************************************************************************************************/
uint8 emosSemQuery (EMOS_EVENT_T *pevent, EMOS_SEM_DATA_T *pdata)
{
    uint8  i;
    uint8 *psrc;
    uint8 *pdest;
    
    EMOS_ENTER_CRITICAL();
    if (pevent->osEventType != EMOS_EVENT_TYPE_SEM)
    {   /* Validate event block type */
        EMOS_EXIT_CRITICAL();
        return (EMOS_ERR_EVENT_TYPE);
    }
    
    pdata->osEventGrp = pevent->osEventGrp; /* Copy message mailbox wait list*/
    psrc              = &pevent->osEventTbl[0];
    pdest             = &pdata->osEventTbl[0];
    for (i = 0; i < EMOS_EVENT_TBL_SIZE; i++) 
    {
        *pdest++ = *psrc++;   
    }
    pdata->osCnt      = pevent->osEventCnt; /* Get semaphore count */
    EMOS_EXIT_CRITICAL();
    return (EMOS_NO_ERR);
}


#if 0
EMOS_EVENT_T* gTestSem = NULL;
void emos_sem_test()
{
  if(NULL == gTestSem)	
  {
  	gTestSem = emosSemCreate (1);
  }
  emosSemPend(gTestSem,0,&gEmosError);
  //emosSemPend(tSem,-1,&gEmosError);
}

void emos_sem_test2()
{
  if(NULL != gTestSem)
  {	
  	emosSemPost(gTestSem);
  }
}
#endif

#endif


 /*
 * Please add "$" around "Id" and "Log".
 * $Id$
 * $Log$
 *
 */

 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 国产日韩欧美精品一区| 在线一区二区三区| 99精品在线免费| aaa欧美日韩| 色悠悠久久综合| 在线一区二区视频| 欧美一级一区二区| 国产精品毛片无遮挡高清| 久久久.com| 国产精品沙发午睡系列990531| 欧美大胆一级视频| 国产午夜精品理论片a级大结局 | 亚洲国产另类av| 亚洲欧美乱综合| 亚洲成人av一区二区三区| 亚洲成人免费在线| 精品一区二区免费看| 国产精品一区二区你懂的| 色综合久久中文字幕综合网| 日韩电影一区二区三区四区| 老司机午夜精品99久久| 国产激情视频一区二区在线观看| a亚洲天堂av| 欧美乱熟臀69xxxxxx| 日韩一区二区免费电影| 国产日韩精品久久久| 一个色综合av| 91精品国产乱| 国产欧美一区二区精品久导航| 亚洲欧美在线观看| 视频一区在线视频| 成人午夜视频在线| 欧美高清视频www夜色资源网| 日韩一区二区电影网| 国产精品久线观看视频| 亚洲高清久久久| 国产精品99久久久久久久vr| 色综合久久六月婷婷中文字幕| 欧美一区二区三区在| 欧美国产一区二区在线观看| 亚洲国产日日夜夜| 粉嫩嫩av羞羞动漫久久久| 欧美日韩中文字幕一区二区| 久久网这里都是精品| 亚洲成人av在线电影| av电影天堂一区二区在线| 日韩欧美中文一区| 一区二区三区高清| 成人午夜视频在线| 26uuu国产电影一区二区| 亚洲成av人片在www色猫咪| 成人三级伦理片| 日韩精品中文字幕一区| 午夜久久电影网| 免费观看在线综合色| 亚洲综合激情小说| www.亚洲精品| 国产欧美综合在线| 看电影不卡的网站| 欧美精品日日鲁夜夜添| 日韩美女视频一区二区| 国产成人午夜视频| 久久九九国产精品| 久久99久久99精品免视看婷婷 | 老司机一区二区| 欧美一区二区三级| 三级不卡在线观看| 欧美日韩免费高清一区色橹橹 | 在线观看亚洲成人| 亚洲免费视频成人| 一本大道综合伊人精品热热 | 国产午夜亚洲精品不卡 | 国产日韩欧美一区二区三区乱码| 久久av中文字幕片| 精品嫩草影院久久| 国产一区二区中文字幕| 久久久久国产精品人| 国产精品影视在线| 日本一区二区三区四区在线视频| 激情五月激情综合网| 欧美精品一区二区三区很污很色的| 日韩电影一区二区三区四区| 日韩免费高清av| 狠狠色丁香婷综合久久| 久久精品人人做人人综合 | 国产v综合v亚洲欧| 国产精品国产三级国产普通话三级 | 欧美性大战久久久久久久蜜臀| 亚洲区小说区图片区qvod| 99re视频这里只有精品| 一区二区三区在线视频观看| 欧美亚洲一区二区在线观看| 日韩电影在线观看网站| 亚洲精品在线免费播放| 成人福利在线看| 亚洲一区二区三区视频在线 | 久久99深爱久久99精品| 久久精品在这里| 91久久精品一区二区三区| 午夜精品久久久久久久99水蜜桃| 666欧美在线视频| 国产成人亚洲综合a∨婷婷 | 风间由美性色一区二区三区| 国产精品福利电影一区二区三区四区| 91国产成人在线| 久久成人羞羞网站| 亚洲人成在线观看一区二区| 欧美日韩一级二级三级| 国产精品77777| 一区二区视频在线看| 欧美r级在线观看| 一本色道久久加勒比精品| 日本午夜精品视频在线观看| 国产精品欧美经典| 91精品国产综合久久久久久久久久| 国产精品一区免费在线观看| 亚洲精品视频免费看| 精品国产免费视频| 欧美亚洲国产bt| 国产乱理伦片在线观看夜一区 | 美女尤物国产一区| 亚洲黄色性网站| 久久久久久久久久久久久女国产乱| 日本一区二区免费在线| 欧美精品久久一区| 91最新地址在线播放| 国产精品综合二区| 日韩高清在线电影| 一区二区三区四区国产精品| 久久久久久9999| 日韩一级大片在线| 欧美日韩亚洲高清一区二区| 成人黄色av电影| 国产精品一品二品| 久久精品二区亚洲w码| 亚洲电影激情视频网站| 亚洲丝袜自拍清纯另类| 日本一区二区三区在线观看| 精品成人一区二区三区四区| 91精品国产综合久久久久久久 | 色综合亚洲欧洲| 成人综合在线视频| 国产精品亚洲视频| 国产麻豆精品在线观看| 日本91福利区| 裸体健美xxxx欧美裸体表演| 日韩在线播放一区二区| 午夜精品影院在线观看| 午夜精品福利一区二区三区av| 一级中文字幕一区二区| 一区二区三区免费看视频| 亚洲三级在线看| 亚洲色图在线看| 亚洲人成精品久久久久| 亚洲欧美日韩国产一区二区三区| 亚洲色图.com| 亚洲综合小说图片| 五月天亚洲精品| 麻豆精品在线看| 国产一区二区剧情av在线| 国产精品99久久久久久久vr| 国产99久久久国产精品潘金网站| 久久99热这里只有精品| 国产成人在线网站| 国产成人精品免费一区二区| 成人18精品视频| 国产精品视频yy9299一区| 亚洲精品中文字幕乱码三区| 亚洲午夜影视影院在线观看| 亚洲国产成人av| 久久精品国产99国产| 成人精品视频一区二区三区尤物| 91一区在线观看| 欧美色图在线观看| 日韩精品一区二区三区在线| 国产欧美一区二区精品忘忧草| 日韩美女久久久| 久久超碰97中文字幕| www.欧美日韩国产在线| 欧美午夜不卡视频| 久久无码av三级| 亚洲国产wwwccc36天堂| 国产一区二区三区四区在线观看| 99久久婷婷国产精品综合| 51午夜精品国产| 国产精品网站在线播放| 亚洲a一区二区| 国产激情一区二区三区| 欧美日韩国产一区| 欧美国产日本视频| 日韩国产在线一| 高清不卡在线观看av| 欧美三级日韩三级国产三级| 国产日产亚洲精品系列| 婷婷综合另类小说色区| www.久久精品| 日本一区二区免费在线| 国产精品成人网| 久久99这里只有精品|