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

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

?? os_sem.c

?? ucos操作系統在s3c44b0上的移植
?? 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一区二区三区免费野_久草精品视频
亚洲久本草在线中文字幕| 欧美激情一区二区三区不卡| heyzo一本久久综合| 国产大陆a不卡| 国产99精品国产| 国产成人av一区二区三区在线 | 欧美日本一道本在线视频| 91麻豆国产精品久久| 99这里只有精品| 色哟哟精品一区| 欧美美女激情18p| 91精品国产高清一区二区三区| 制服丝袜亚洲播放| 欧美xxxxx裸体时装秀| 久久综合色天天久久综合图片| 久久久精品天堂| 国产精品久久久久久久久快鸭| 亚洲精品综合在线| 亚洲v日本v欧美v久久精品| 日韩avvvv在线播放| 国产精品中文字幕日韩精品| 丁香婷婷综合五月| 在线观看91视频| 日韩一区二区免费在线观看| 2024国产精品| 日韩毛片一二三区| 日本成人在线不卡视频| 国产乱妇无码大片在线观看| 99久久国产综合精品色伊| 欧美三级电影在线观看| 精品国产一区二区三区久久久蜜月| 国产日韩精品一区二区三区 | 欧美日韩午夜在线视频| 日韩精品中文字幕一区| 日本一区二区三区久久久久久久久不| 亚洲欧美色图小说| 精彩视频一区二区三区| 色94色欧美sute亚洲线路一ni| 欧美日韩极品在线观看一区| 精品国产自在久精品国产| 亚洲精品成人天堂一二三| 久久精品国产久精国产爱| 91美女片黄在线观看91美女| 精品国产电影一区二区| 一区二区三区精品视频| 国产精品99久久久久久似苏梦涵| 日本黄色一区二区| 国产精品网友自拍| 精品一二线国产| 884aa四虎影成人精品一区| 亚洲你懂的在线视频| 国产美女视频91| 日韩欧美亚洲另类制服综合在线| 亚洲欧洲日产国产综合网| 国产乱理伦片在线观看夜一区| 欧美日韩成人一区| 亚洲尤物视频在线| av在线不卡电影| 国产午夜亚洲精品理论片色戒| 日韩和欧美一区二区| 欧美在线高清视频| 亚洲免费视频中文字幕| 不卡的av电影| 欧美国产国产综合| 国产成人综合视频| 久久一日本道色综合| 美国欧美日韩国产在线播放| 宅男在线国产精品| 日韩精彩视频在线观看| 欧美精品xxxxbbbb| 日本大胆欧美人术艺术动态| 欧美日韩国产精品成人| 污片在线观看一区二区| 精品视频免费在线| 午夜精品成人在线| 欧美人xxxx| 全部av―极品视觉盛宴亚洲| 欧美日韩国产欧美日美国产精品| 亚洲激情在线激情| 欧美日韩国产精品成人| 日本中文字幕不卡| 日韩亚洲电影在线| 精品亚洲成a人在线观看| 久久精品一二三| 懂色av一区二区夜夜嗨| 中文字幕一区二区三区色视频| 波多野结衣在线aⅴ中文字幕不卡| 国产精品看片你懂得 | 一区二区三区日本| 欧美性一级生活| 日韩福利视频网| 久久婷婷久久一区二区三区| 丁香一区二区三区| 亚洲国产精品久久久久婷婷884 | 国产在线日韩欧美| 国产欧美日韩三级| 91麻豆免费看片| 日韩av一区二区在线影视| 欧美va在线播放| 9i看片成人免费高清| 香蕉成人啪国产精品视频综合网 | 亚洲欧美一区二区三区久本道91| 色诱视频网站一区| 麻豆91精品视频| 综合久久给合久久狠狠狠97色| 欧美色大人视频| 国产在线观看免费一区| 亚洲欧美国产毛片在线| 日韩三级.com| 色综合中文综合网| 日韩一区二区三区视频在线观看| 国产一区二区视频在线| 亚洲午夜日本在线观看| 久久综合视频网| 欧美三级三级三级| 粉嫩aⅴ一区二区三区四区五区| 亚洲午夜羞羞片| 国产精品国产三级国产aⅴ入口| 欧美日韩国产高清一区二区三区| 国产精品系列在线观看| 丝袜美腿高跟呻吟高潮一区| 国产精品视频在线看| 日韩欧美二区三区| 欧美日韩视频在线第一区 | 在线一区二区三区做爰视频网站| 麻豆国产91在线播放| 亚洲永久精品国产| 国产精品久久久久精k8 | 亚洲精品日日夜夜| 国产日韩综合av| 26uuu精品一区二区| 欧美一区二区三区性视频| 在线观看亚洲专区| 成人动漫在线一区| 国产精品1024| 美女爽到高潮91| 日韩国产精品久久| 亚洲成年人影院| 亚洲一区二区三区在线看| 国产精品盗摄一区二区三区| 精品国产不卡一区二区三区| 日韩一区二区三区视频在线观看| 欧美日韩精品一区二区三区| 一本在线高清不卡dvd| 92国产精品观看| 色综合色狠狠综合色| av中文字幕亚洲| jizzjizzjizz欧美| eeuss鲁一区二区三区| 大美女一区二区三区| 国产白丝精品91爽爽久久| 国产一区二区调教| 国产91综合网| 成人免费视频免费观看| 成人一区二区三区视频在线观看| 韩国女主播成人在线| 国产在线精品视频| 国产精品影音先锋| 从欧美一区二区三区| 成人黄色片在线观看| 97国产精品videossex| 91福利精品第一导航| 欧美亚洲禁片免费| 欧美一区二区三区系列电影| 日韩三级中文字幕| 国产亚洲精品免费| ...xxx性欧美| 夜夜精品视频一区二区| 五月天一区二区| 国产一区二区影院| 91小宝寻花一区二区三区| 欧美性三三影院| 日韩欧美国产高清| 中文字幕欧美激情| 亚洲自拍偷拍图区| 久久精品二区亚洲w码| 丁香激情综合五月| 欧美中文字幕一二三区视频| 欧美一级午夜免费电影| 国产拍揄自揄精品视频麻豆| 亚洲免费在线观看| 久久99蜜桃精品| 99视频精品在线| 欧美精品免费视频| 国产精品嫩草影院av蜜臀| 亚洲高清视频的网址| 国产麻豆日韩欧美久久| 在线观看一区二区视频| 久久久亚洲综合| 一区二区三区不卡视频在线观看 | 亚洲一区在线电影| 国产一区二区福利| 在线观看成人免费视频| 久久精品人人爽人人爽| 亚洲自拍偷拍麻豆| 成人性生交大片免费看在线播放| 欧美高清dvd| 亚洲日穴在线视频| 国产乱码字幕精品高清av | 成人精品gif动图一区|