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

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

?? os_mutex.c

?? uCos_II到ARM7的移植
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2006, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_MUTEX.C
* By      : Jean J. Labrosse
* Version : V2.83
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include <ucos_ii.h>
#endif


#if OS_MUTEX_EN > 0
/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

#define  OS_MUTEX_KEEP_LOWER_8   0x00FFu
#define  OS_MUTEX_KEEP_UPPER_8   0xFF00u

#define  OS_MUTEX_AVAILABLE      0x00FFu

/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

static  void  OSMutex_RdyAtPrio(OS_TCB *ptcb, INT8U prio);

/*$PAGE*/
/*
*********************************************************************************************************
*                                   ACCEPT MUTUAL EXCLUSION SEMAPHORE
*
* Description: This  function checks the mutual exclusion semaphore to see if a resource is available.
*              Unlike OSMutexPend(), OSMutexAccept() 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
*
*              err        is a pointer to an error code which will be returned to your application:
*                            OS_NO_ERR          if the call was successful.
*                            OS_ERR_EVENT_TYPE  if 'pevent' is not a pointer to a mutex
*                            OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
*                            OS_ERR_PEND_ISR     if you called this function from an ISR
*                            OS_ERR_PIP_LOWER    If the priority of the task that owns the Mutex is
*                                                HIGHER (i.e. a lower number) than the PIP.  This error
*                                                indicates that you did not set the PIP higher (lower
*                                                number) than ALL the tasks that compete for the Mutex.
*                                                Unfortunately, this is something that could not be
*                                                detected when the Mutex is created because we don't know
*                                                what tasks will be using the Mutex.
*
* Returns    : == 1       if the resource is available, the mutual exclusion semaphore is acquired
*              == 0       a) if the resource is not available
*                         b) you didn't pass a pointer to a mutual exclusion semaphore
*                         c) you called this function from an ISR
*
* Warning(s) : This function CANNOT be called from an ISR because mutual exclusion semaphores are
*              intended to be used by tasks only.
*********************************************************************************************************
*/

#if OS_MUTEX_ACCEPT_EN > 0
INT8U  OSMutexAccept (OS_EVENT *pevent, INT8U *err)
{
    INT8U      pip;                                    /* Priority Inheritance Priority (PIP)          */
#if OS_CRITICAL_METHOD == 3                            /* Allocate storage for CPU status register     */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (err == (INT8U *)0) {                           /* Validate 'err'                               */
        return (0);
    }
    if (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'                            */
        *err = OS_ERR_PEVENT_NULL;
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {  /* Validate event block type                    */
        *err = OS_ERR_EVENT_TYPE;
        return (0);
    }
    if (OSIntNesting > 0) {                            /* Make sure it's not called from an ISR        */
        *err = OS_ERR_PEND_ISR;
        return (0);
    }
    OS_ENTER_CRITICAL();                               /* Get value (0 or 1) of Mutex                  */
    pip = (INT8U)(pevent->OSEventCnt >> 8);            /* Get PIP from mutex                           */
    if ((pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {
        pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8;   /*      Mask off LSByte (Acquire Mutex)         */
        pevent->OSEventCnt |= OSTCBCur->OSTCBPrio;     /*      Save current task priority in LSByte    */
        pevent->OSEventPtr  = (void *)OSTCBCur;        /*      Link TCB of task owning Mutex           */
        if (OSTCBCur->OSTCBPrio <= pip) {              /*      PIP 'must' have a SMALLER prio ...      */
            OS_EXIT_CRITICAL();                        /*      ... than current task!                  */
            *err  = OS_ERR_PIP_LOWER;
        } else {
            OS_EXIT_CRITICAL();
            *err  = OS_NO_ERR;
        }
        return (1);
    }
    OS_EXIT_CRITICAL();
    *err = OS_NO_ERR;
    return (0);
}
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                  CREATE A MUTUAL EXCLUSION SEMAPHORE
*
* Description: This function creates a mutual exclusion semaphore.
*
* Arguments  : prio          is the priority to use when accessing the mutual exclusion semaphore.  In
*                            other words, when the semaphore is acquired and a higher priority task
*                            attempts to obtain the semaphore then the priority of the task owning the
*                            semaphore is raised to this priority.  It is assumed that you will specify
*                            a priority that is LOWER in value than ANY of the tasks competing for the
*                            mutex.
*
*              err           is a pointer to an error code which will be returned to your application:
*                               OS_NO_ERR           if the call was successful.
*                               OS_ERR_CREATE_ISR   if you attempted to create a MUTEX from an ISR
*                               OS_PRIO_EXIST       if a task at the priority inheritance priority
*                                                   already exist.
*                               OS_ERR_PEVENT_NULL  No more event control blocks available.
*                               OS_PRIO_INVALID     if the priority you specify is higher that the
*                                                   maximum allowed (i.e. > OS_LOWEST_PRIO)
*
* Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                            created mutex.
*              == (void *)0  if an error is detected.
*
* Note(s)    : 1) The LEAST significant 8 bits of '.OSEventCnt' are used to hold the priority number
*                 of the task owning the mutex or 0xFF if no task owns the mutex.
*
*              2) The MOST  significant 8 bits of '.OSEventCnt' are used to hold the priority number
*                 to use to reduce priority inversion.
*********************************************************************************************************
*/

OS_EVENT  *OSMutexCreate (INT8U prio, INT8U *err)
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0;
#endif



#if OS_ARG_CHK_EN > 0
    if (err == (INT8U *)0) {                               /* Validate 'err'                           */
        return ((OS_EVENT *)0);
    }
    if (prio >= OS_LOWEST_PRIO) {                          /* Validate PIP                             */
        *err = OS_PRIO_INVALID;
        return ((OS_EVENT *)0);
    }
#endif
    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_CREATE_ISR;                          /* ... can't CREATE mutex from an ISR       */
        return ((OS_EVENT *)0);
    }
    OS_ENTER_CRITICAL();
    if (OSTCBPrioTbl[prio] != (OS_TCB *)0) {               /* Mutex priority must not already exist    */
        OS_EXIT_CRITICAL();                                /* Task already exist at priority ...       */
        *err = OS_PRIO_EXIST;                              /* ... inheritance priority                 */
        return ((OS_EVENT *)0);
    }
    OSTCBPrioTbl[prio] = (OS_TCB *)1;                      /* Reserve the table entry                  */
    pevent             = OSEventFreeList;                  /* Get next free event control block        */
    if (pevent == (OS_EVENT *)0) {                         /* See if an ECB was available              */
        OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* No, Release the table entry              */
        OS_EXIT_CRITICAL();
        *err               = OS_ERR_PEVENT_NULL;           /* No more event control blocks             */
        return (pevent);
    }
    OSEventFreeList        = (OS_EVENT *)OSEventFreeList->OSEventPtr;   /* Adjust the free list        */
    OS_EXIT_CRITICAL();
    pevent->OSEventType    = OS_EVENT_TYPE_MUTEX;
    pevent->OSEventCnt     = (INT16U)((INT16U)prio << 8) | OS_MUTEX_AVAILABLE; /* Resource is avail.   */
    pevent->OSEventPtr     = (void *)0;                                 /* No task owning the mutex    */
#if OS_EVENT_NAME_SIZE > 1
    pevent->OSEventName[0] = '?';
    pevent->OSEventName[1] = OS_ASCII_NUL;
#endif
    OS_EventWaitListInit(pevent);
    *err                   = OS_NO_ERR;
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                          DELETE A MUTEX
*
* Description: This function deletes a mutual exclusion semaphore and readies all tasks pending on the it.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired mutex.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete mutex ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the mutex 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 mutex was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the MUTEX from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the mutex
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a mutex
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the mutex was successfully deleted.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美一区二区精品性色| 国产精品初高中害羞小美女文| 久久久久亚洲蜜桃| 一区二区三区免费观看| 国产精选一区二区三区| 欧美日韩极品在线观看一区| 国产精品伦一区| 激情五月播播久久久精品| 午夜国产不卡在线观看视频| 精品国产乱码久久久久久影片| 国产精品福利一区| 国产精品69久久久久水密桃| 日韩午夜中文字幕| 亚洲一区在线视频| 色婷婷一区二区| 一区二区三区欧美激情| 99久久精品费精品国产一区二区| 国产网站一区二区| 国产一区二区三区精品视频| 日韩欧美久久一区| 毛片av一区二区三区| 欧美一区永久视频免费观看| 精一区二区三区| 精品国产乱码久久久久久闺蜜| 蜜臀av性久久久久蜜臀aⅴ流畅| 日韩欧美一区二区视频| 日韩avvvv在线播放| 日韩一级成人av| 韩国欧美一区二区| 国产精品视频yy9299一区| 国产尤物一区二区| 伊人性伊人情综合网| 精品一区二区三区影院在线午夜 | 欧美网站一区二区| 亚洲人成网站影音先锋播放| 成人激情图片网| 欧美手机在线视频| 亚洲国产人成综合网站| 88在线观看91蜜桃国自产| 国产成+人+日韩+欧美+亚洲| 国产精品自在欧美一区| 国产精品久久福利| 国产一区二区中文字幕| 久久夜色精品一区| 美女精品一区二区| 精品日本一线二线三线不卡| 日韩成人伦理电影在线观看| 91视频在线观看免费| 亚洲色图制服诱惑 | 精品女同一区二区| 秋霞国产午夜精品免费视频| 欧美电影影音先锋| 精品一区二区精品| 亚洲色图第一区| 欧美日韩国产综合一区二区三区| 国产精品午夜在线| 色婷婷久久久综合中文字幕| 丝袜美腿亚洲一区二区图片| 国产精品久久久久久久久久久免费看| 99久久亚洲一区二区三区青草 | 日韩精品亚洲专区| 91精品在线一区二区| 狠狠色丁香婷婷综合| 亚洲精品亚洲人成人网| 欧美精品xxxxbbbb| 成人精品视频.| 日韩精品一二三四| 国产欧美日韩久久| 久久久久久夜精品精品免费| 色婷婷综合久久久中文字幕| 欧美性生活大片视频| 成人精品视频一区| 国产一区二区三区久久久| 韩国女主播一区二区三区| 免费成人av在线| 国产精品美女久久久久av爽李琼| 色综合久久久久综合体桃花网| 久久精品999| 五月激情丁香一区二区三区| 日韩综合小视频| www.成人网.com| 亚洲欧美一区二区三区久本道91| 久久精品国产精品青草| 91精品综合久久久久久| 国内精品视频666| 久久久久国产精品免费免费搜索| 成人av综合在线| 亚洲综合色噜噜狠狠| 欧美另类久久久品| 懂色av一区二区三区免费观看| 在线观看免费视频综合| 国产欧美日韩卡一| 久久天天做天天爱综合色| 日韩精品一区二区三区在线观看| 制服丝袜在线91| 51久久夜色精品国产麻豆| 成人黄色电影在线| 国产盗摄视频一区二区三区| 国产乱人伦偷精品视频不卡| 亚洲一区中文在线| 亚洲一区在线观看视频| 亚洲一卡二卡三卡四卡无卡久久| 国产精品天美传媒| 中文字幕免费不卡| 亚洲人成影院在线观看| 亚洲激情中文1区| 亚洲午夜精品一区二区三区他趣| 亚洲精品成a人| 日韩精品午夜视频| 国产一区999| 成人福利电影精品一区二区在线观看 | 国产嫩草影院久久久久| 久久久久久一二三区| 久久久久久久久岛国免费| 久久国产精品露脸对白| 国产一区二区视频在线| 欧美日韩久久一区| 久久精品人人做人人爽97| 亚洲444eee在线观看| 粉嫩av一区二区三区| 欧美一区午夜精品| 国产精品看片你懂得| 亚洲欧美另类久久久精品2019| 136国产福利精品导航| 一区二区三区四区在线| 精品一区精品二区高清| 欧美日韩不卡一区| 青青草97国产精品免费观看| 精品奇米国产一区二区三区| 最新久久zyz资源站| 日韩一级黄色片| 欧美三级蜜桃2在线观看| 丁香一区二区三区| 另类综合日韩欧美亚洲| 一区二区三区不卡在线观看| 欧美精品亚洲一区二区在线播放| 色88888久久久久久影院按摩| 国产精品亚洲а∨天堂免在线| 亚洲影视资源网| 色噜噜狠狠色综合中国| 亚洲精品视频一区| 国产成人精品亚洲午夜麻豆| 欧美日韩亚洲综合一区| 国产精品美女久久久久久2018| 日本伊人午夜精品| 欧美另类一区二区三区| 国产精品国产三级国产aⅴ中文 | 日本韩国欧美在线| 欧美网站大全在线观看| 中文在线资源观看网站视频免费不卡| 九九精品一区二区| 欧美另类变人与禽xxxxx| 亚洲女同女同女同女同女同69| 国产一区二区不卡老阿姨| 在线观看不卡一区| 综合婷婷亚洲小说| 国产麻豆精品theporn| 欧美精品一区二区三区四区 | 男男视频亚洲欧美| 777亚洲妇女| 国产1区2区3区精品美女| 国产精品国产三级国产普通话三级| 欧美少妇一区二区| 精品一二三四在线| 亚洲欧洲www| 久久国产福利国产秒拍| 国产欧美日韩综合| 91视频免费看| 国产精品第五页| 一本久道久久综合中文字幕| 亚洲国产精品久久不卡毛片| 欧美人妇做爰xxxⅹ性高电影| 99精品视频一区二区| 色综合久久久网| 欧美视频精品在线| 久久免费午夜影院| 欧美韩国日本综合| 中文字幕一区二区三区在线不卡 | 91网站在线播放| 在线观看日韩一区| 欧美久久久一区| 日韩一级二级三级| 99视频超级精品| 日韩不卡在线观看日韩不卡视频| 亚洲品质自拍视频| 欧美大度的电影原声| 91色在线porny| 国产一区二区三区国产| 一区二区三区成人| 国产日韩精品一区二区浪潮av | 欧美日韩中文精品| 国产乱码一区二区三区| 亚洲一区二区三区视频在线播放| 久久日一线二线三线suv| 在线观看日产精品| 99久久久国产精品免费蜜臀| 国产精品91一区二区| 天天爽夜夜爽夜夜爽精品视频| 国产精品网站一区| 精品久久五月天|