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

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

?? os_sem.c

?? 一個完整的串口轉以太網服務器的源代碼.硬件平臺是LPC2214 ARM7處理器+8019AS以太網控制器.軟件平臺是UCOSII+一個第三方的TCP/IP協議棧.
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2001, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.h"
#endif

#if OS_SEM_EN > 0
/*
*********************************************************************************************************
*                                           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,
*                         if 'pevent' is a NULL pointer or,
*                         if you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

#if OS_SEM_ACCEPT_EN > 0
INT16U  OSSemAccept (OS_EVENT *pevent)
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;
#endif    
    INT16U     cnt;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
#endif
    OS_ENTER_CRITICAL();
    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
*********************************************************************************************************
*/

OS_EVENT  *OSSemCreate (INT16U cnt)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_EVENT  *pevent;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        return ((OS_EVENT *)0);                            /* ... can't CREATE from an ISR             */
    }
    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                      */
        OS_EventWaitListInit(pevent);
    }
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         DELETE A SEMAPHORE
*
* Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            semaphore.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete semaphore ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the semaphore even if tasks are waiting.
*                                                    In this case, all the tasks pending will be readied.
*
*              err           is a pointer to an error code that can contain one of the following values:
*                            OS_NO_ERR               The call was successful and the semaphore was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the semaphore from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the semaphore
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a semaphore
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the semaphore was successfully deleted.
*
* Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
*                 the semaphore MUST check the return code of OSSemPend().
*              2) OSSemAccept() callers will not know that the intended semaphore has been deleted unless
*                 they check 'pevent' to see that it's a NULL pointer.
*              3) This call can potentially disable interrupts for a long time.  The interrupt disable
*                 time is directly proportional to the number of tasks waiting on the semaphore.
*              4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful in
*                 applications where the semaphore is used for mutual exclusion because the resource(s)
*                 will no longer be guarded by the semaphore.
*********************************************************************************************************
*/

#if OS_SEM_DEL_EN > 0
OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *err = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on semaphore    */
        tasks_waiting = TRUE;                              /* Yes                                      */
    } else {
        tasks_waiting = FALSE;                             /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == FALSE) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 OSEventFreeList     = pevent;             /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *err = OS_NO_ERR;
                 return ((OS_EVENT *)0);                   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err = OS_ERR_TASK_WAITING;
                 return (pevent);
             }

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for semaphore    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             OSEventFreeList     = pevent;                 /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err = OS_NO_ERR;
             return ((OS_EVENT *)0);                       /* Semaphore has been deleted               */

        default:
             OS_EXIT_CRITICAL();
             *err = OS_ERR_INVALID_OPT;
             return (pevent);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲激情自拍偷拍| 天堂在线一区二区| 亚洲大片在线观看| 精品一区二区三区日韩| 99精品在线观看视频| 日韩三级精品电影久久久| 中文字幕在线不卡一区| 久久99久久久欧美国产| 在线亚洲免费视频| 国产欧美va欧美不卡在线| 天天影视网天天综合色在线播放| 国产激情一区二区三区| 欧美一级欧美一级在线播放| 亚洲欧美日韩中文播放| 国产99精品视频| 欧美va亚洲va香蕉在线| 日韩1区2区3区| 欧美日韩一区二区三区不卡| 亚洲色欲色欲www| 成人性视频免费网站| www精品美女久久久tv| 免费观看91视频大全| 欧美日韩三级一区| 亚洲老妇xxxxxx| 成人看片黄a免费看在线| 国产欧美精品在线观看| 国产69精品久久久久777| 久久婷婷国产综合国色天香| 毛片基地黄久久久久久天堂| 欧美美女激情18p| 亚洲国产精品一区二区久久| 欧美图片一区二区三区| 亚洲第一综合色| 欧美日韩一区不卡| 亚洲成人免费看| 欧美一区二区在线观看| 视频精品一区二区| 日韩丝袜情趣美女图片| 六月丁香婷婷色狠狠久久| 日韩欧美久久久| 国产一区二区毛片| 中文字幕av不卡| 色一情一乱一乱一91av| 亚洲成av人影院| 日韩欧美色综合| 国产成人午夜精品5599| 综合在线观看色| 欧美视频一二三区| 久久66热偷产精品| 国产日韩三级在线| 欧美亚洲日本国产| 极品美女销魂一区二区三区免费| 久久这里只有精品视频网| 成人网页在线观看| 一区二区三区国产| 欧美一级高清片| 国产成人超碰人人澡人人澡| 亚洲人精品一区| 欧美一区二区三区日韩| 国产很黄免费观看久久| 亚洲精品写真福利| 精品国产成人系列| 一本色道久久综合精品竹菊| 天堂成人国产精品一区| 日本一区二区三区四区| 欧美日韩精品综合在线| 韩国精品主播一区二区在线观看| 亚洲人快播电影网| 欧美va日韩va| 欧美日韩一区国产| 成人午夜伦理影院| 日本aⅴ亚洲精品中文乱码| 国产精品久久午夜| 日韩欧美在线综合网| 99免费精品在线观看| 日韩和的一区二区| 视频一区视频二区中文| 成人一区二区三区| 日日夜夜精品免费视频| 亚洲国产成人在线| 欧美一区二区三区视频在线观看| 成人午夜精品在线| 国产在线看一区| 三级影片在线观看欧美日韩一区二区 | 成人性色生活片免费看爆迷你毛片| 一区二区三区中文字幕| 国产亚洲午夜高清国产拍精品| 色欧美乱欧美15图片| 国产精品99久久不卡二区| 亚洲国产精品欧美一二99| 欧美国产日本韩| 日韩女同互慰一区二区| 在线观看一区二区视频| 成人激情文学综合网| 久久66热偷产精品| 免费在线观看不卡| 婷婷综合在线观看| 亚洲成人自拍偷拍| 樱花影视一区二区| 成人欧美一区二区三区| 国产欧美日韩综合精品一区二区| 欧美va日韩va| 精品裸体舞一区二区三区| 欧美精品色综合| 欧美性猛交xxxx黑人交| 色哟哟一区二区三区| 91视频在线观看免费| 成人avav在线| 99久久伊人久久99| 不卡一区二区三区四区| caoporen国产精品视频| 成人97人人超碰人人99| 国产精品影视在线观看| 国产精品一区二区久久不卡| 久久精品国产秦先生| 久久99精品久久久久久| 美女mm1313爽爽久久久蜜臀| 青青草国产成人99久久| 免费在线观看不卡| 国产呦精品一区二区三区网站| 精品一区二区三区久久| 精品系列免费在线观看| 国产在线播放一区三区四| 懂色av一区二区夜夜嗨| 99久久久精品| 91精品办公室少妇高潮对白| 在线观看国产精品网站| 欧美色综合网站| 欧美一级久久久| 国产婷婷色一区二区三区四区| 国产精品午夜春色av| 亚洲女与黑人做爰| 视频一区欧美日韩| 国产麻豆成人传媒免费观看| 成人激情开心网| 欧美色图第一页| 欧美xxxx老人做受| 亚洲欧美影音先锋| 午夜视黄欧洲亚洲| 国产一本一道久久香蕉| 成人av网站在线| 欧美精品国产精品| 久久久精品天堂| 一区二区三区波多野结衣在线观看| 亚洲123区在线观看| 国产一区久久久| 色又黄又爽网站www久久| 欧美一区二区三区免费视频| 久久五月婷婷丁香社区| 亚洲制服丝袜在线| 国产高清无密码一区二区三区| 97精品久久久午夜一区二区三区| 欧美日韩一区二区三区在线| 久久久久久久久久久久久久久99 | 亚洲va欧美va人人爽| 蜜桃av噜噜一区二区三区小说| 国产成人精品综合在线观看| 欧美在线制服丝袜| 久久久久久久久久久久久夜| 尤物av一区二区| 国产精品香蕉一区二区三区| 欧美综合久久久| 欧美韩国日本综合| 日本va欧美va瓶| 欧美综合色免费| 一区在线观看视频| 精品一区二区三区蜜桃| 欧美人与性动xxxx| 中文字幕视频一区| 国产精品一线二线三线| 欧美日韩夫妻久久| 椎名由奈av一区二区三区| 国产真实乱对白精彩久久| 91精品1区2区| 亚洲色图欧美激情| 成人一区二区在线观看| 精品国产一区二区在线观看| 午夜精彩视频在线观看不卡| 99精品热视频| 欧美极品美女视频| 国产精品99久久久久| 日韩精品一区二区三区中文精品| 伊人性伊人情综合网| av一区二区久久| 中文字幕乱码一区二区免费| 韩国女主播一区二区三区| 91麻豆精品国产91久久久| 亚洲一区二区三区激情| 色综合中文字幕国产| 国产午夜亚洲精品羞羞网站| 久久草av在线| www欧美成人18+| 国产麻豆9l精品三级站| 久久久久9999亚洲精品| 国产福利一区二区| 国产拍揄自揄精品视频麻豆| 国产乱码一区二区三区| 久久免费国产精品 | 亚洲欧美二区三区| eeuss影院一区二区三区 |