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

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

?? os_sem.c

?? ucos-II在S3C44BO下的移植
?? 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麻豆免费看| 欧美性大战久久| 久久国产精品无码网站| 亚洲成人先锋电影| 亚洲高清免费视频| 伊人婷婷欧美激情| 亚洲网友自拍偷拍| 亚洲国产精品久久久男人的天堂| 亚洲精品免费视频| 亚洲v日本v欧美v久久精品| 一级女性全黄久久生活片免费| 日韩理论电影院| 亚洲一区二区在线视频| 一个色在线综合| 日本不卡一二三区黄网| 黄网站免费久久| 久久99国产精品成人| 国产一二精品视频| 成人av网站大全| 欧美丝袜自拍制服另类| 日韩欧美国产小视频| 精品国产污污免费网站入口 | 国产精品电影院| 亚洲精品网站在线观看| 亚洲成人av电影在线| 麻豆精品新av中文字幕| 国产精品99久久久久久似苏梦涵| 成人午夜免费视频| 日本韩国欧美国产| 久久综合久久鬼色中文字| 国产嫩草影院久久久久| 亚洲精品视频免费看| 美女视频第一区二区三区免费观看网站| 久久成人免费电影| 91国偷自产一区二区三区成为亚洲经典 | 北条麻妃一区二区三区| 欧美婷婷六月丁香综合色| 日韩欧美在线网站| 国产精品嫩草影院av蜜臀| 一二三四区精品视频| 国产精品一级片在线观看| 色综合天天综合| 精品电影一区二区| 亚洲午夜精品网| 色综合激情五月| 日韩欧美二区三区| 一区二区三区高清在线| 国产在线不卡一区| 欧美日韩国产大片| 自拍偷拍亚洲综合| 国内国产精品久久| 91 com成人网| 亚洲精品伦理在线| 国产成人福利片| 欧美成人欧美edvon| 亚洲成av人影院在线观看网| 不卡区在线中文字幕| 精品免费一区二区三区| 香蕉乱码成人久久天堂爱免费| 成人黄色在线视频| 久久精品这里都是精品| 日本不卡一区二区| 8v天堂国产在线一区二区| 亚洲精品久久久蜜桃| 欧美一级片在线观看| 一区二区三区四区在线播放 | 国产丝袜欧美中文另类| 免费精品视频最新在线| 欧美一区二区在线看| 亚洲va欧美va人人爽| 色综合久久综合| 亚洲激情五月婷婷| 在线观看日韩精品| 亚洲精品一二三| 91网站最新网址| 亚洲欧美日韩一区| 91最新地址在线播放| 中文字幕一区二区三| 成人福利电影精品一区二区在线观看 | 99精品视频在线免费观看| 国产午夜精品一区二区| 国产精品白丝jk黑袜喷水| 久久久综合视频| 国产一区二区三区免费| 久久新电视剧免费观看| 久久99久久精品| 国产欧美日本一区二区三区| 国产精品99久| 中文字幕一区二区三区在线观看 | 欧美在线综合视频| 亚洲国产色一区| 日韩一区二区电影在线| 国产精品亚洲一区二区三区妖精 | 国产99精品在线观看| 亚洲色图制服诱惑| 欧美日韩在线免费视频| 免费在线欧美视频| 欧美不卡一区二区| 波多野结衣视频一区| 亚洲欧美日本韩国| 91精品中文字幕一区二区三区| 久久国产精品免费| 欧美国产日产图区| 在线免费亚洲电影| 久久精品国产色蜜蜜麻豆| 国产精品国产自产拍在线| 91成人在线精品| 久久66热re国产| 中文字幕亚洲一区二区av在线| 欧美日韩国产片| 国产精品一二二区| 五月天视频一区| 欧美—级在线免费片| 欧美丰满高潮xxxx喷水动漫| 国产成人免费xxxxxxxx| 婷婷成人激情在线网| 国产欧美日韩精品一区| 欧美色爱综合网| 成年人午夜久久久| 日本人妖一区二区| 中文字幕亚洲视频| 久久奇米777| 欧美精选一区二区| 91在线码无精品| 国产成人综合自拍| 麻豆91在线播放免费| 亚洲乱码中文字幕综合| 国产亚洲婷婷免费| 欧美一区二区三区四区高清| 日本伦理一区二区| 成人影视亚洲图片在线| 琪琪久久久久日韩精品| 一区二区三区精密机械公司| 国产午夜精品一区二区三区四区| 3d成人动漫网站| 精品视频在线看| 在线免费不卡电影| 99视频精品全部免费在线| 国内成人免费视频| 免费人成网站在线观看欧美高清| 亚洲影院免费观看| 成人免费一区二区三区视频| 国产亚洲1区2区3区| 91精品蜜臀在线一区尤物| 在线视频你懂得一区| 91丝袜高跟美女视频| 97精品国产露脸对白| 波多野结衣在线一区| 波多野结衣在线aⅴ中文字幕不卡| 国产毛片精品视频| 国产黄色91视频| 国产高清精品网站| 在线观看国产日韩| 色拍拍在线精品视频8848| 成人av午夜电影| 色系网站成人免费| 91视频www| 一本到高清视频免费精品| 一本色道亚洲精品aⅴ| 99国产精品一区| 色综合久久99| 欧美日本一道本在线视频| 欧美日韩国产乱码电影| 欧美一区二区三区四区五区| 日韩一区二区电影| 国产日韩欧美精品一区| 中文字幕五月欧美| 亚洲欧美日韩精品久久久久| 亚洲伊人色欲综合网| 天堂精品中文字幕在线| 久久99精品久久久久久国产越南| 精品一区二区av| 91在线视频播放地址| 欧美日韩精品福利| 精品久久久久久久人人人人传媒| 久久伊人中文字幕| 成人欧美一区二区三区1314| 亚洲综合色成人| 开心九九激情九九欧美日韩精美视频电影| 激情综合色播激情啊| 菠萝蜜视频在线观看一区| 欧美日韩专区在线| 久久久久久久久久久久久夜| 亚洲男人都懂的| 免费一区二区视频| 不卡在线视频中文字幕| 欧美色综合天天久久综合精品| 日韩亚洲欧美一区| 成人免费一区二区三区视频| 日韩av高清在线观看| 国产 欧美在线| 欧美精品在线观看一区二区| 国产视频一区二区在线观看| 亚洲一区在线观看视频| 国产一二三精品| 在线播放中文字幕一区| 国产精品免费视频观看| 日本亚洲三级在线| 91视频你懂的| 欧美精品一区二区三区高清aⅴ|