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

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

?? os_sem.c

?? UC/OS-II移植到s3c2440代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2002, 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                      */
        pevent->OSEventPtr  = (void *)0;                   /* Unlink from ECB free list                */
        OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
    }
    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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲综合另类| 一区二区三区在线观看网站| 亚洲国产一区二区在线播放| 国产一区二区三区四| 欧美群妇大交群的观看方式| 国产精品久久影院| 狠狠v欧美v日韩v亚洲ⅴ| 欧美三级日本三级少妇99| 国产精品国产成人国产三级| 国产麻豆精品视频| 欧美一区二区三区的| 亚洲国产一区在线观看| 色又黄又爽网站www久久| 中文字幕av免费专区久久| 国内精品久久久久影院一蜜桃| 欧美日韩精品高清| 夜色激情一区二区| 91视频你懂的| 国产精品不卡在线观看| 国产剧情一区在线| 久久综合999| 黄页视频在线91| 欧美成人女星排行榜| 日韩精品乱码av一区二区| 欧美自拍偷拍一区| 樱桃国产成人精品视频| 91热门视频在线观看| 中文字幕日本乱码精品影院| 国产sm精品调教视频网站| 国产亚洲女人久久久久毛片| 国产尤物一区二区| 欧美一个色资源| 日韩精品成人一区二区在线| 在线播放日韩导航| 青草av.久久免费一区| 91精品免费在线| 日本在线播放一区二区三区| 91精品国产综合久久福利软件 | 精品久久一区二区三区| 看电影不卡的网站| 精品国产三级电影在线观看| 久久精品久久综合| 久久久久久久久久美女| 国产91清纯白嫩初高中在线观看| 中文字幕电影一区| 成人av资源在线| 亚洲三级电影网站| 欧美在线一二三| 日韩不卡在线观看日韩不卡视频| 日韩欧美中文一区| 国产一区二区精品久久| 中文在线资源观看网站视频免费不卡| 成人中文字幕电影| 亚洲精品自拍动漫在线| 欧美日韩精品福利| 麻豆中文一区二区| 久久精品一区二区| 99久久综合精品| 亚洲一二三区视频在线观看| 91精品国产综合久久国产大片| 韩国女主播成人在线观看| 国产色一区二区| 91在线观看地址| 亚洲综合av网| 日韩欧美亚洲一区二区| 国产盗摄女厕一区二区三区| 亚洲图片另类小说| 欧美丰满高潮xxxx喷水动漫| 国产一区二区三区av电影| 国产精品全国免费观看高清 | 一本色道**综合亚洲精品蜜桃冫| 午夜视频一区二区三区| 26uuu精品一区二区| 成年人国产精品| 亚洲一区二区av在线| 日韩欧美www| 95精品视频在线| 日韩高清不卡在线| 亚洲国产精品二十页| 欧美日韩三级视频| 国产美女久久久久| 亚洲午夜一区二区| 久久久精品天堂| 在线看国产一区| 激情图区综合网| 亚洲美女在线一区| 欧美电影免费提供在线观看| 波多野结衣91| 麻豆视频观看网址久久| 国产精品美女久久久久久久 | 91久久精品一区二区| 久久成人麻豆午夜电影| 亚洲免费在线视频一区 二区| 日韩欧美在线影院| 色婷婷精品大视频在线蜜桃视频| 精品一区二区久久| 亚洲三级电影网站| 久久久精品国产免大香伊| 欧美在线|欧美| 九九精品视频在线看| 一区二区三区四区中文字幕| 国产亚洲一二三区| 717成人午夜免费福利电影| 成人免费看黄yyy456| 午夜精品福利一区二区蜜股av | 久久久午夜精品| 欧美日韩一区成人| 福利91精品一区二区三区| 亚洲v精品v日韩v欧美v专区| 中文字幕av一区 二区| 日韩欧美高清在线| 欧美日韩五月天| 91在线你懂得| 国产不卡视频在线播放| 蜜臀av性久久久久蜜臀aⅴ | 中文字幕中文字幕在线一区 | 91麻豆精品国产91久久久资源速度| 成人污污视频在线观看| 久久91精品国产91久久小草| 亚洲成人精品一区| 亚洲免费伊人电影| 国产精品热久久久久夜色精品三区| 欧美大片顶级少妇| 这里是久久伊人| 欧美三电影在线| 91在线视频观看| 成人听书哪个软件好| 极品少妇xxxx精品少妇| 三级影片在线观看欧美日韩一区二区| 亚洲精品乱码久久久久久久久 | 在线成人免费观看| 欧美自拍偷拍一区| 色综合中文综合网| 欧美精品第1页| 在线观看国产91| av一区二区三区四区| 高清不卡在线观看| 国产成人精品在线看| 国产一区二区三区日韩| 美女高潮久久久| 麻豆精品视频在线| 免费成人深夜小野草| 日韩高清在线不卡| 日韩avvvv在线播放| 天天操天天色综合| 亚洲小少妇裸体bbw| 亚洲国产aⅴ成人精品无吗| 亚洲综合视频在线| 一区二区三区日本| 一区二区三区精品视频| 亚洲美女电影在线| 一区二区三区四区五区视频在线观看| 亚洲免费毛片网站| 亚洲精品视频在线观看免费| 亚洲欧美日韩在线| 亚洲美女电影在线| 一区二区三区高清不卡| 亚洲高清免费视频| 日本中文字幕一区二区视频| 日本不卡123| 毛片av中文字幕一区二区| 九九热在线视频观看这里只有精品| 激情综合色丁香一区二区| 国产在线国偷精品免费看| 国产高清在线精品| av一区二区久久| 在线亚洲一区二区| 在线不卡一区二区| 精品国产乱子伦一区| 久久精品人人做人人爽人人| 欧美国产国产综合| 亚洲视频你懂的| 亚洲午夜久久久久中文字幕久| 婷婷丁香久久五月婷婷| 精品一区二区三区在线观看| 国产精品亚洲午夜一区二区三区 | 91在线小视频| 欧美亚洲愉拍一区二区| 91麻豆精品国产无毒不卡在线观看| 日韩欧美精品在线视频| 久久久久国产精品厨房| 中文字幕在线不卡视频| 亚洲一区视频在线观看视频| 舔着乳尖日韩一区| 国产一区二区三区免费看| 99久久免费精品| 欧美理论电影在线| 久久免费电影网| 亚洲另类春色校园小说| 日韩av电影一区| 岛国精品一区二区| 欧美亚洲国产怡红院影院| 日韩精品最新网址| 成人欧美一区二区三区1314| 亚洲第一精品在线| 国产成人亚洲精品狼色在线| 欧美亚洲日本一区| 久久久噜噜噜久噜久久综合| 亚洲欧美另类久久久精品2019| 蜜桃免费网站一区二区三区|