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

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

?? os_task.c

?? uCOS-II在三星44B0開發板上的移植
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                            TASK MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_TASK.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

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

/*
*********************************************************************************************************
*                                        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_NO_ERR        is the call was successful
*              OS_PRIO_INVALID  if the priority you specify is higher that the maximum allowed
*                               (i.e. >= OS_LOWEST_PRIO)
*              OS_PRIO_EXIST    if the new priority already exist.
*              OS_PRIO_ERR      there is no task with the specified OLD priority (i.e. the OLD task does
*                               not exist.
*********************************************************************************************************
*/

#if OS_TASK_CHANGE_PRIO_EN > 0
INT8U  OSTaskChangePrio (INT8U oldprio, INT8U newprio)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR    cpu_sr;
#endif

#if OS_EVENT_EN > 0
    OS_EVENT    *pevent;
#endif

    OS_TCB      *ptcb;
    INT8U        x;
    INT8U        y;
    INT8U        bitx;
    INT8U        bity;
    INT8U        y_old;


#if OS_ARG_CHK_EN > 0
    if (oldprio >= OS_LOWEST_PRIO) {
	    if (oldprio != OS_PRIO_SELF) {
            return (OS_PRIO_INVALID);
		}
	}
    if (newprio >= OS_LOWEST_PRIO) {
        return (OS_PRIO_INVALID);
    }
#endif
    OS_ENTER_CRITICAL();
    if (OSTCBPrioTbl[newprio] != (OS_TCB *)0) {                 /* New priority must not already exist */
        OS_EXIT_CRITICAL();
        return (OS_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_PRIO_ERR);
    }                                       
    y                     = newprio >> 3;                       /* Yes, compute new TCB fields         */
    bity                  = OSMapTbl[y];
    x                     = newprio & 0x07;
    bitx                  = OSMapTbl[x];
    OSTCBPrioTbl[oldprio] = (OS_TCB *)0;                        /* Remove TCB from old priority        */
    OSTCBPrioTbl[newprio] = ptcb;                               /* Place pointer to TCB @ new priority */
    y_old                 = ptcb->OSTCBY;
    if ((OSRdyTbl[y_old] & ptcb->OSTCBBitX) != 0x00) {          /* If task is ready make it not        */
        OSRdyTbl[y_old] &= ~ptcb->OSTCBBitX;
        if (OSRdyTbl[y_old] == 0x00) {
            OSRdyGrp &= ~ptcb->OSTCBBitY;
        }
        OSRdyGrp    |= bity;                                    /* Make new priority ready to run      */
        OSRdyTbl[y] |= bitx;
#if OS_EVENT_EN > 0
    } else {                                                    /* Task was not ready ...              */
        pevent = ptcb->OSTCBEventPtr;
        if (pevent != (OS_EVENT *)0) {                          /* ... remove from event wait list     */
            pevent->OSEventTbl[y_old] &= ~ptcb->OSTCBBitX;
            if (pevent->OSEventTbl[y_old] == 0) {
                pevent->OSEventGrp &= ~ptcb->OSTCBBitY;
            }
            pevent->OSEventGrp    |= bity;                      /* Add new priority to wait list       */
            pevent->OSEventTbl[y] |= bitx;
        }
#endif
    }
    ptcb->OSTCBPrio = newprio;                                  /* Set new task priority               */
    ptcb->OSTCBY    = y;
    ptcb->OSTCBX    = x;
    ptcb->OSTCBBitY = bity;
    ptcb->OSTCBBitX = bitx;
    OS_EXIT_CRITICAL();
    OS_Sched();                                                 /* Run highest priority task ready     */
    return (OS_NO_ERR);
}
#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
*
*              pdata    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 'pdata' as follows:
*
*                           void Task (void *pdata)
*                           {
*                               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_NO_ERR        if the function was successful.
*              OS_PRIO_EXIT     if the task priority already exist
*                               (each task MUST have a unique priority).
*              OS_PRIO_INVALID  if the priority you specify is higher that the maximum allowed
*                               (i.e. >= OS_LOWEST_PRIO)
*********************************************************************************************************
*/

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


#if OS_ARG_CHK_EN > 0
    if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
        return (OS_PRIO_INVALID);
    }
#endif
    OS_ENTER_CRITICAL();
    if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
        OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others from doing ...  */
                                             /* ... the same thing until task is created.              */
        OS_EXIT_CRITICAL();
        psp = (OS_STK *)OSTaskStkInit(task, pdata, ptos, 0);    /* Initialize the task's stack         */
        err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
        if (err == OS_NO_ERR) {
            OS_ENTER_CRITICAL();
            OSTaskCtr++;                                        /* Increment the #tasks counter        */
            OS_EXIT_CRITICAL();
            if (OSRunning == 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_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
*
*              pdata    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 'pdata' as follows:
*
*                           void Task (void *pdata)
*                           {
*                               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.
*
* Returns    : OS_NO_ERR        if the function was successful.
*              OS_PRIO_EXIT     if the task priority already exist
*                               (each task MUST have a unique priority).
*              OS_PRIO_INVALID  if the priority you specify is higher that the maximum allowed
*                               (i.e. > OS_LOWEST_PRIO)
*********************************************************************************************************
*/
/*$PAGE*/
#if OS_TASK_CREATE_EXT_EN > 0
INT8U  OSTaskCreateExt (void   (*task)(void *pd),
                        void    *pdata,
                        OS_STK  *ptos,
                        INT8U    prio,
                        INT16U   id,
                        OS_STK  *pbos,
                        INT32U   stk_size,
                        void    *pext,
                        INT16U   opt)
{
#if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register               */
    OS_CPU_SR  cpu_sr;
#endif
    OS_STK    *psp;
    INT8U      err;


#if OS_ARG_CHK_EN > 0
    if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
        return (OS_PRIO_INVALID);
    }
#endif
    OS_ENTER_CRITICAL();
    if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
        OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others from doing ...  */
                                             /* ... the same thing until task is created.              */
        OS_EXIT_CRITICAL();

        OS_TaskStkClr(pbos, stk_size, opt);                    /* Clear the task stack (if needed)     */

        psp = (OS_STK *)OSTaskStkInit(task, pdata, ptos, opt); /* Initialize the task's stack          */
        err = OS_TCBInit(prio, psp, pbos, id, stk_size, pext, opt);
        if (err == OS_NO_ERR) {
            OS_ENTER_CRITICAL();
            OSTaskCtr++;                                       /* Increment the #tasks counter         */
            OS_EXIT_CRITICAL();
            if (OSRunning == TRUE) {                           /* Find HPT if multitasking has started */
                OS_Sched();
            }
        } else {
            OS_ENTER_CRITICAL();
            OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* Make this priority avail. to others  */
            OS_EXIT_CRITICAL();
        }
        return (err);
    }
    OS_EXIT_CRITICAL();
    return (OS_PRIO_EXIST);
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
*                                            DELETE A TASK
*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美不卡在线视频| 丝袜脚交一区二区| 日本aⅴ精品一区二区三区| 成人精品视频一区二区三区尤物| 久久蜜桃香蕉精品一区二区三区| 高清国产午夜精品久久久久久| 国产日韩欧美一区二区三区综合| 偷窥国产亚洲免费视频| 555www色欧美视频| 国产真实乱对白精彩久久| 精品动漫一区二区三区在线观看| 日韩精品乱码免费| 欧美α欧美αv大片| 国产精品综合二区| 亚洲靠逼com| 在线亚洲一区观看| 亚洲 欧美综合在线网络| 欧美一区二区三区人| 久久国产精品色| 91在线观看地址| 三级在线观看一区二区| 欧美日韩久久久一区| 蜜臀久久99精品久久久久久9| aaa国产一区| 日韩一区二区三区免费看| 国内精品写真在线观看| 亚洲一区欧美一区| 91免费视频网| 亚洲少妇30p| 欧美日韩国产精品自在自线| 国内不卡的二区三区中文字幕 | 日韩精品一区二区三区老鸭窝| 国产老肥熟一区二区三区| 玉足女爽爽91| 精品国产一区久久| 丁香六月综合激情| 日韩国产一二三区| 亚洲精品视频在线观看免费| 精品国产一区二区三区忘忧草 | 精品一二三四区| 欧美成人一区二区| 欧美日韩极品在线观看一区| 日本免费在线视频不卡一不卡二| 国产精品12区| 精品一二三四区| 亚洲成av人片在线观看无码| 久久久午夜电影| 在线视频欧美精品| 激情综合网最新| 日本一区二区三区dvd视频在线| 在线日韩av片| 国产成人综合在线观看| 麻豆国产91在线播放| 肉肉av福利一精品导航| 一区二区三区四区激情| 国产精品久久久久久久久久久免费看| 91精品一区二区三区久久久久久 | 欧美在线你懂的| 国产精品一区二区x88av| 亚洲一区二区三区免费视频| 国产欧美精品一区二区色综合朱莉| 欧美tickling挠脚心丨vk| 91精品欧美一区二区三区综合在 | 免费在线一区观看| 免费欧美在线视频| 久久99久久精品| 国产一区二区三区免费在线观看 | 色综合天天综合网天天狠天天| www.av亚洲| 欧美探花视频资源| 欧美日韩大陆一区二区| 欧美欧美欧美欧美| 精品捆绑美女sm三区| 欧美精品一区二区久久久| 久久先锋影音av| 中文字幕一区不卡| 亚洲成人动漫一区| 婷婷综合在线观看| 五月激情综合网| 蜜臀av在线播放一区二区三区| 天天综合天天综合色| 蜜桃视频在线观看一区| 国产传媒日韩欧美成人| 91香蕉视频mp4| 欧美日韩精品一区二区天天拍小说| 欧美一级在线视频| 中文字幕av一区二区三区| 一区二区三区四区不卡视频| 国产精品欧美一级免费| 亚洲精品菠萝久久久久久久| 亚洲gay无套男同| 懂色av一区二区三区免费观看| 欧美在线制服丝袜| 国产农村妇女精品| 香蕉成人伊视频在线观看| 国产精品99久久久久久似苏梦涵 | 欧美日韩中文精品| 94-欧美-setu| 日韩一级在线观看| 中文久久乱码一区二区| 夜夜嗨av一区二区三区网页| 亚洲综合小说图片| 天天射综合影视| 国产福利一区在线观看| 在线播放视频一区| 亚洲欧美国产高清| 国产成人午夜视频| 日韩午夜在线观看| 亚洲国产日产av| 99精品视频在线观看免费| 日韩一级高清毛片| 五月婷婷综合网| 色播五月激情综合网| 国产精品欧美一区二区三区| 久久99精品国产91久久来源| 7777精品久久久大香线蕉| 洋洋av久久久久久久一区| 成人av网站在线观看免费| 久久美女高清视频| 国产精品小仙女| 亚洲精品一区二区三区香蕉| 日本成人中文字幕在线视频| 欧美日本一道本| 午夜精品影院在线观看| 91国偷自产一区二区使用方法| 国产精品日产欧美久久久久| 国产精品白丝jk黑袜喷水| 欧美国产精品一区二区| 国产aⅴ综合色| 欧美国产欧美综合| 成人黄页毛片网站| 国产精品电影一区二区三区| 成人性生交大片免费看中文网站| 日本一区二区三区高清不卡| 欧美性极品少妇| 一区二区三区在线免费| 色婷婷av一区二区三区大白胸| 中文字幕日韩一区二区| 麻豆精品一区二区av白丝在线| 在线观看视频一区二区欧美日韩| 一区二区三区四区激情| 欧美日韩小视频| 日韩精品欧美精品| 在线观看精品一区| 蜜桃av一区二区| 69久久夜色精品国产69蝌蚪网| 日产国产高清一区二区三区| 日韩免费观看高清完整版| 国产在线日韩欧美| 国产精品第五页| 欧美日韩精品一区二区| 久久99深爱久久99精品| 欧美激情一区在线| 在线视频你懂得一区二区三区| 亚洲精品国产成人久久av盗摄 | 欧美午夜电影网| 天堂久久久久va久久久久| 精品88久久久久88久久久| 成人app在线观看| 亚洲香肠在线观看| 久久人人爽爽爽人久久久| 91丨九色丨黑人外教| 免费看黄色91| 国产精品美女一区二区在线观看| 在线观看国产精品网站| 午夜不卡av在线| 国产精品全国免费观看高清| 欧美日韩一级片网站| 国产一区久久久| 亚洲久本草在线中文字幕| 日韩免费看的电影| 91免费观看国产| 久久99久久久欧美国产| 亚洲综合激情网| 一区二区三区av电影| 欧美成人精品福利| 日本韩国精品在线| 国产精品66部| 日韩二区三区在线观看| 亚洲欧美自拍偷拍色图| 精品盗摄一区二区三区| 久久精品国产一区二区| 亚洲欧洲三级电影| 欧美精品1区2区3区| av不卡在线播放| 国模娜娜一区二区三区| 亚洲伦理在线免费看| 久久久久久久精| 日韩精品一区二区三区三区免费 | 欧美一卡2卡三卡4卡5免费| av电影一区二区| 国产精品综合二区| 蜜桃一区二区三区在线| 亚洲第一福利一区| 最近中文字幕一区二区三区| 久久久不卡网国产精品一区| 欧美xxxxxxxxx| 精品欧美乱码久久久久久| 日韩精品一区在线观看| 欧美电影影音先锋|