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

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

?? os_task.c

?? ucos2/2.90-STM32
?? C
?? 第 1 頁 / 共 4 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                            TASK MANAGEMENT
*
*                              (c) Copyright 1992-2009, Micrium, Weston, FL
*                                           All Rights Reserved
*
* File    : OS_TASK.C
* By      : Jean J. Labrosse
* Version : V2.91
*
* LICENSING TERMS:
* ---------------
*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.
* If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license
* its use in your product. We provide ALL the source code for your convenience and to help you experience
* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a
* licensing fee.
*********************************************************************************************************
*/

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

/*$PAGE*/
/*
*********************************************************************************************************
*                                        CHANGE PRIORITY OF A TASK
*
* Description: This function allows you to change the priority of a task dynamically.  Note that the new
*              priority MUST be available.
*
* Arguments  : oldp     is the old priority
*
*              newp     is the new priority
*
* Returns    : OS_ERR_NONE            is the call was successful
*              OS_ERR_PRIO_INVALID    if the priority you specify is higher that the maximum allowed
*                                     (i.e. >= OS_LOWEST_PRIO)
*              OS_ERR_PRIO_EXIST      if the new priority already exist.
*              OS_ERR_PRIO            there is no task with the specified OLD priority (i.e. the OLD task does
*                                     not exist.
*              OS_ERR_TASK_NOT_EXIST  if the task is assigned to a Mutex PIP.
*********************************************************************************************************
*/

#if OS_TASK_CHANGE_PRIO_EN > 0u
INT8U  OSTaskChangePrio (INT8U  oldprio,
                         INT8U  newprio)
{
#if (OS_EVENT_EN)
    OS_EVENT  *pevent;
#if (OS_EVENT_MULTI_EN > 0u)
    OS_EVENT **pevents;
#endif
#endif
    OS_TCB    *ptcb;
    INT8U      y_new;
    INT8U      x_new;
    INT8U      y_old;
    OS_PRIO    bity_new;
    OS_PRIO    bitx_new;
    OS_PRIO    bity_old;
    OS_PRIO    bitx_old;
#if OS_CRITICAL_METHOD == 3u
    OS_CPU_SR  cpu_sr = 0u;                                 /* Storage for CPU status register         */
#endif


/*$PAGE*/
#if OS_ARG_CHK_EN > 0u
    if (oldprio >= OS_LOWEST_PRIO) {
        if (oldprio != OS_PRIO_SELF) {
            return (OS_ERR_PRIO_INVALID);
        }
    }
    if (newprio >= OS_LOWEST_PRIO) {
        return (OS_ERR_PRIO_INVALID);
    }
#endif
    OS_ENTER_CRITICAL();
    if (OSTCBPrioTbl[newprio] != (OS_TCB *)0) {             /* New priority must not already exist     */
        OS_EXIT_CRITICAL();
        return (OS_ERR_PRIO_EXIST);
    }
    if (oldprio == OS_PRIO_SELF) {                          /* See if changing self                    */
        oldprio = OSTCBCur->OSTCBPrio;                      /* Yes, get priority                       */
    }
    ptcb = OSTCBPrioTbl[oldprio];
    if (ptcb == (OS_TCB *)0) {                              /* Does task to change exist?              */
        OS_EXIT_CRITICAL();                                 /* No, can't change its priority!          */
        return (OS_ERR_PRIO);
    }
    if (ptcb == OS_TCB_RESERVED) {                          /* Is task assigned to Mutex               */
        OS_EXIT_CRITICAL();                                 /* No, can't change its priority!          */
        return (OS_ERR_TASK_NOT_EXIST);
    }
#if OS_LOWEST_PRIO <= 63u
    y_new                 = (INT8U)(newprio >> 3u);         /* Yes, compute new TCB fields             */
    x_new                 = (INT8U)(newprio & 0x07u);
#else
    y_new                 = (INT8U)((INT8U)(newprio >> 4u) & 0x0Fu);
    x_new                 = (INT8U)(newprio & 0x0Fu);
#endif
    bity_new              = (OS_PRIO)(1uL << y_new);
    bitx_new              = (OS_PRIO)(1uL << x_new);

    OSTCBPrioTbl[oldprio] = (OS_TCB *)0;                    /* Remove TCB from old priority            */
    OSTCBPrioTbl[newprio] =  ptcb;                          /* Place pointer to TCB @ new priority     */
    y_old                 =  ptcb->OSTCBY;
    bity_old              =  ptcb->OSTCBBitY;
    bitx_old              =  ptcb->OSTCBBitX;
    if ((OSRdyTbl[y_old] &   bitx_old) != 0u) {             /* If task is ready make it not            */
         OSRdyTbl[y_old] &= (OS_PRIO)~bitx_old;
         if (OSRdyTbl[y_old] == 0u) {
             OSRdyGrp &= (OS_PRIO)~bity_old;
         }
         OSRdyGrp        |= bity_new;                       /* Make new priority ready to run          */
         OSRdyTbl[y_new] |= bitx_new;
    }

#if (OS_EVENT_EN)
    pevent = ptcb->OSTCBEventPtr;
    if (pevent != (OS_EVENT *)0) {
        pevent->OSEventTbl[y_old] &= (OS_PRIO)~bitx_old;    /* Remove old task prio from wait list     */
        if (pevent->OSEventTbl[y_old] == 0u) {
            pevent->OSEventGrp    &= (OS_PRIO)~bity_old;
        }
        pevent->OSEventGrp        |= bity_new;              /* Add    new task prio to   wait list     */
        pevent->OSEventTbl[y_new] |= bitx_new;
    }
#if (OS_EVENT_MULTI_EN > 0u)
    if (ptcb->OSTCBEventMultiPtr != (OS_EVENT **)0) {
        pevents =  ptcb->OSTCBEventMultiPtr;
        pevent  = *pevents;
        while (pevent != (OS_EVENT *)0) {
            pevent->OSEventTbl[y_old] &= (OS_PRIO)~bitx_old;   /* Remove old task prio from wait lists */
            if (pevent->OSEventTbl[y_old] == 0u) {
                pevent->OSEventGrp    &= (OS_PRIO)~bity_old;
            }
            pevent->OSEventGrp        |= bity_new;          /* Add    new task prio to   wait lists    */
            pevent->OSEventTbl[y_new] |= bitx_new;
            pevents++;
            pevent                     = *pevents;
        }
    }
#endif
#endif

    ptcb->OSTCBPrio = newprio;                              /* Set new task priority                   */
    ptcb->OSTCBY    = y_new;
    ptcb->OSTCBX    = x_new;
    ptcb->OSTCBBitY = bity_new;
    ptcb->OSTCBBitX = bitx_new;
    OS_EXIT_CRITICAL();
    if (OSRunning == OS_TRUE) {
        OS_Sched();                                         /* Find new highest priority task          */
    }
    return (OS_ERR_NONE);
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
*                                            CREATE A TASK
*
* Description: This function is used to have uC/OS-II manage the execution of a task.  Tasks can either
*              be created prior to the start of multitasking or by a running task.  A task cannot be
*              created by an ISR.
*
* Arguments  : task     is a pointer to the task's code
*
*              p_arg    is a pointer to an optional data area which can be used to pass parameters to
*                       the task when the task first executes.  Where the task is concerned it thinks
*                       it was invoked and passed the argument 'p_arg' as follows:
*
*                           void Task (void *p_arg)
*                           {
*                               for (;;) {
*                                   Task code;
*                               }
*                           }
*
*              ptos     is a pointer to the task's top of stack.  If the configuration constant
*                       OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
*                       memory to low memory).  'pstk' will thus point to the highest (valid) memory
*                       location of the stack.  If OS_STK_GROWTH is set to 0, 'pstk' will point to the
*                       lowest memory location of the stack and the stack will grow with increasing
*                       memory locations.
*
*              prio     is the task's priority.  A unique priority MUST be assigned to each task and the
*                       lower the number, the higher the priority.
*
* Returns    : OS_ERR_NONE             if the function was successful.
*              OS_PRIO_EXIT            if the task priority already exist
*                                      (each task MUST have a unique priority).
*              OS_ERR_PRIO_INVALID     if the priority you specify is higher that the maximum allowed
*                                      (i.e. >= OS_LOWEST_PRIO)
*              OS_ERR_TASK_CREATE_ISR  if you tried to create a task from an ISR.
*********************************************************************************************************
*/

#if OS_TASK_CREATE_EN > 0u
INT8U  OSTaskCreate (void   (*task)(void *p_arg),
                     void    *p_arg,
                     OS_STK  *ptos,
                     INT8U    prio)
{
    OS_STK    *psp;
    INT8U      err;
#if OS_CRITICAL_METHOD == 3u                 /* Allocate storage for CPU status register               */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL_IEC61508
    if (OSSafetyCriticalStartFlag == OS_TRUE) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0u
    if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
        return (OS_ERR_PRIO_INVALID);
    }
#endif
    OS_ENTER_CRITICAL();
    if (OSIntNesting > 0u) {                 /* Make sure we don't create the task from within an ISR  */
        OS_EXIT_CRITICAL();
        return (OS_ERR_TASK_CREATE_ISR);
    }
    if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
        OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ...  */
                                             /* ... the same thing until task is created.              */
        OS_EXIT_CRITICAL();
        psp = OSTaskStkInit(task, p_arg, ptos, 0u);             /* Initialize the task's stack         */
        err = OS_TCBInit(prio, psp, (OS_STK *)0, 0u, 0u, (void *)0, 0u);
        if (err == OS_ERR_NONE) {
            if (OSRunning == OS_TRUE) {      /* Find highest priority task if multitasking has started */
                OS_Sched();
            }
        } else {
            OS_ENTER_CRITICAL();
            OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others                 */
            OS_EXIT_CRITICAL();
        }
        return (err);
    }
    OS_EXIT_CRITICAL();
    return (OS_ERR_PRIO_EXIST);
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
*                                     CREATE A TASK (Extended Version)
*
* Description: This function is used to have uC/OS-II manage the execution of a task.  Tasks can either
*              be created prior to the start of multitasking or by a running task.  A task cannot be
*              created by an ISR.  This function is similar to OSTaskCreate() except that it allows
*              additional information about a task to be specified.
*
* Arguments  : task      is a pointer to the task's code
*
*              p_arg     is a pointer to an optional data area which can be used to pass parameters to
*                        the task when the task first executes.  Where the task is concerned it thinks
*                        it was invoked and passed the argument 'p_arg' as follows:
*
*                            void Task (void *p_arg)
*                            {
*                                for (;;) {
*                                    Task code;
*                                }
*                            }
*
*              ptos      is a pointer to the task's top of stack.  If the configuration constant
*                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
*                        memory to low memory).  'ptos' will thus point to the highest (valid) memory
*                        location of the stack.  If OS_STK_GROWTH is set to 0, 'ptos' will point to the
*                        lowest memory location of the stack and the stack will grow with increasing
*                        memory locations.  'ptos' MUST point to a valid 'free' data item.
*
*              prio      is the task's priority.  A unique priority MUST be assigned to each task and the
*                        lower the number, the higher the priority.
*
*              id        is the task's ID (0..65535)
*
*              pbos      is a pointer to the task's bottom of stack.  If the configuration constant
*                        OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
*                        memory to low memory).  'pbos' will thus point to the LOWEST (valid) memory
*                        location of the stack.  If OS_STK_GROWTH is set to 0, 'pbos' will point to the
*                        HIGHEST memory location of the stack and the stack will grow with increasing
*                        memory locations.  'pbos' MUST point to a valid 'free' data item.
*
*              stk_size  is the size of the stack in number of elements.  If OS_STK is set to INT8U,
*                        'stk_size' corresponds to the number of bytes available.  If OS_STK is set to
*                        INT16U, 'stk_size' contains the number of 16-bit entries available.  Finally, if
*                        OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit entries
*                        available on the stack.
*
*              pext      is a pointer to a user supplied memory location which is used as a TCB extension.
*                        For example, this user memory can hold the contents of floating-point registers
*                        during a context switch, the time each task takes to execute, the number of times
*                        the task has been switched-in, etc.
*
*              opt       contains additional information (or options) about the behavior of the task.  The
*                        LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can be application
*                        specific.  See OS_TASK_OPT_??? in uCOS-II.H.  Current choices are:
*
*                        OS_TASK_OPT_STK_CHK      Stack checking to be allowed for the task
*                        OS_TASK_OPT_STK_CLR      Clear the stack when the task is created
*                        OS_TASK_OPT_SAVE_FP      If the CPU has floating-point registers, save them

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美一区二区在线观看| 国产成人免费av在线| 狠狠色丁香久久婷婷综合_中| 不卡av电影在线播放| 欧美一区二区三级| 一区二区三区四区在线| 国产成人aaaa| 精品第一国产综合精品aⅴ| 亚洲午夜成aⅴ人片| 91蝌蚪porny九色| 国产网站一区二区三区| 精品无人区卡一卡二卡三乱码免费卡| 色哟哟欧美精品| 国产精品电影一区二区| 国产aⅴ综合色| 亚洲精品一区二区三区影院| 日av在线不卡| 欧美精品日韩一本| 亚洲福利一区二区三区| 色综合久久久久综合体| 国产精品剧情在线亚洲| 国产精华液一区二区三区| 精品国产百合女同互慰| 精品中文字幕一区二区小辣椒 | www久久精品| 日本不卡视频在线| 欧美一区二区三区四区久久| 亚洲成人免费电影| 欧美日韩国产综合一区二区三区| 一区二区三区日韩欧美精品| 一本大道av伊人久久综合| 亚洲欧美激情插| 日本二三区不卡| 亚洲综合一二三区| 欧美三级一区二区| 亚洲电影一区二区| 91精品国产日韩91久久久久久| 三级影片在线观看欧美日韩一区二区| 欧美亚洲综合在线| 亚洲成人激情综合网| 欧美日韩免费视频| 午夜视频一区二区| 欧美不卡一二三| 国产剧情一区在线| 国产精品乱人伦中文| 97久久久精品综合88久久| 最新国产成人在线观看| 色婷婷综合激情| 高潮精品一区videoshd| 中文字幕国产精品一区二区| 99re成人精品视频| 亚洲国产人成综合网站| 精品欧美一区二区三区精品久久 | 亚洲午夜一区二区三区| 911精品产国品一二三产区 | 午夜久久福利影院| 国产欧美在线观看一区| 色天天综合色天天久久| 日韩电影免费在线看| 国产欧美精品区一区二区三区| 99国产精品国产精品久久| 午夜影院久久久| 久久久久久99精品| 色欧美乱欧美15图片| 麻豆国产91在线播放| 国产精品三级在线观看| 欧美日韩二区三区| 成人黄色小视频在线观看| 性久久久久久久久久久久| 国产日韩影视精品| 欧美高清一级片在线| 成人午夜av电影| 男人的天堂久久精品| 中文字幕国产一区二区| 欧美一区二区视频在线观看| 成人性视频网站| 免播放器亚洲一区| 亚洲三级电影全部在线观看高清| 3d动漫精品啪啪一区二区竹菊| 成人伦理片在线| 精品一区二区免费| 亚洲第一在线综合网站| 中文字幕在线不卡国产视频| 日韩一区二区三区视频| 欧美综合天天夜夜久久| 成人精品一区二区三区四区| 免费成人在线视频观看| 一二三四社区欧美黄| 久久综合精品国产一区二区三区| 欧美丝袜丝交足nylons| 91色porny在线视频| 国产一区二区精品久久| 日韩av网站在线观看| 亚洲一区二区在线免费观看视频| 亚洲国产精品av| 久久久久久99精品| 日韩欧美黄色影院| 91精品国产综合久久香蕉的特点| 91香蕉视频mp4| 99久久精品情趣| 成人一级黄色片| 国产一区二区三区在线观看免费视频| 亚洲成a天堂v人片| 亚洲二区在线观看| 亚洲一区二区三区免费视频| 国产精品国产精品国产专区不蜜| 日韩欧美精品在线视频| 欧美一区二区在线观看| 91.com在线观看| 欧美日韩国产乱码电影| 欧美日韩小视频| 欧美日韩黄视频| 欧美精品乱人伦久久久久久| 欧美疯狂做受xxxx富婆| 欧美性做爰猛烈叫床潮| 在线观看不卡视频| 在线日韩av片| 在线播放中文一区| 欧美一级一级性生活免费录像| 欧美一区二区在线视频| 欧美不卡激情三级在线观看| 26uuu精品一区二区在线观看| 久久亚洲精精品中文字幕早川悠里| 26uuu国产在线精品一区二区| 久久免费看少妇高潮| 国产欧美综合在线| 亚洲欧美日韩国产综合在线| 夜色激情一区二区| 日韩成人av影视| 国精产品一区一区三区mba视频| 国产传媒一区在线| 91蝌蚪porny| 91麻豆精品国产91久久久资源速度| 欧美一区二区三区免费观看视频| 精品噜噜噜噜久久久久久久久试看 | 67194成人在线观看| 欧美电视剧在线观看完整版| 国产亚洲欧洲997久久综合 | 成人免费视频网站在线观看| 色狠狠一区二区三区香蕉| 欧美日韩夫妻久久| 久久久一区二区| 亚洲精品视频一区| 久久国产婷婷国产香蕉| 成人动漫在线一区| 911精品国产一区二区在线| 久久在线观看免费| 亚洲欧美国产毛片在线| 日韩在线一区二区| 成人爽a毛片一区二区免费| 欧美日韩国产首页在线观看| 久久久久久久久久美女| 亚洲一二三四在线| 国产福利一区二区| 欧美精品久久一区二区三区| 欧美国产精品中文字幕| 香蕉影视欧美成人| 成人h动漫精品一区二区| 91精品婷婷国产综合久久性色| 国产情人综合久久777777| 亚洲成av人片在线观看无码| 国产99久久久精品| 91精品国产综合久久精品图片| 日本一区二区在线不卡| 日本不卡视频一二三区| 91国产视频在线观看| 国产亚洲美州欧州综合国| 日韩vs国产vs欧美| 色婷婷精品大在线视频| 国产亚洲精品aa| 久久99精品久久久久久久久久久久| 在线观看亚洲精品| 国产精品国产三级国产有无不卡| 久久疯狂做爰流白浆xx| 欧美久久久久久久久久| 亚洲精品福利视频网站| 成人av集中营| 国产日韩精品一区二区浪潮av| 天天操天天干天天综合网| 欧美在线影院一区二区| 自拍偷拍欧美激情| 成人免费电影视频| 国产欧美日韩另类视频免费观看| 久久精品国产亚洲高清剧情介绍 | 国产午夜精品一区二区| 美女视频黄频大全不卡视频在线播放| 欧美性色aⅴ视频一区日韩精品| 亚洲欧洲在线观看av| 国产盗摄一区二区| 欧美经典一区二区三区| 国产在线精品免费av| 日韩免费观看2025年上映的电影| 婷婷久久综合九色国产成人| 91九色最新地址| 一二三区精品视频| 欧美三级中文字| 婷婷丁香久久五月婷婷| 制服丝袜亚洲精品中文字幕| 丝袜美腿亚洲一区| 日韩亚洲欧美一区二区三区|