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

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

?? os_task.c

?? UCOS移植到三星ARM芯片S3C44B0上程序的范例,并有移植成功后的應用
?? 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一区二区三区免费野_久草精品视频
国产又黄又大久久| 91一区二区三区在线观看| 成人中文字幕合集| 欧美在线免费视屏| 中文字幕不卡三区| 奇米综合一区二区三区精品视频| 丁香六月综合激情| 51久久夜色精品国产麻豆| 亚洲视频一二三区| 久久精品国产精品青草| 欧美视频一区二区三区四区| www精品美女久久久tv| 亚洲一级二级在线| www.亚洲精品| 精品sm捆绑视频| 午夜免费久久看| 色噜噜狠狠色综合欧洲selulu| 欧美zozozo| 免费观看一级欧美片| 欧美日韩精品一区二区| 国产精品理论在线观看| 国产一区二区三区观看| 日韩视频永久免费| 日韩高清在线观看| 欧美日韩亚洲不卡| 亚洲欧美色图小说| 99久久99久久免费精品蜜臀| 久久久美女艺术照精彩视频福利播放| 五月综合激情网| 欧美日韩国产综合视频在线观看| 亚洲欧洲av色图| 成人av电影在线| 国产精品久久午夜| 国产成人精品网址| 久久久精品影视| 福利一区二区在线观看| 精品国偷自产国产一区| 久久99久国产精品黄毛片色诱| 制服丝袜中文字幕一区| 五月天久久比比资源色| 欧美理论片在线| 日韩av网站免费在线| 欧美人与z0zoxxxx视频| 免费成人美女在线观看| 亚洲另类在线制服丝袜| 99久久精品情趣| 亚洲人成小说网站色在线 | 国模冰冰炮一区二区| 久久综合狠狠综合久久激情| 国产精品中文字幕一区二区三区| 欧美成人r级一区二区三区| 美女一区二区视频| 精品国产一二三| 粉嫩蜜臀av国产精品网站| 国产精品久久久久毛片软件| 91官网在线免费观看| 午夜视黄欧洲亚洲| www成人在线观看| av在线一区二区三区| 亚洲图片一区二区| 日韩一区二区在线看| 国产大陆精品国产| 一区二区三区免费看视频| 欧美美女激情18p| 久久超级碰视频| 国产精品美女久久久久久久网站| 95精品视频在线| 亚洲成人先锋电影| 精品国产乱码久久久久久图片| 国产91对白在线观看九色| 一区二区三区在线观看视频| 欧美一卡在线观看| 不卡欧美aaaaa| 日本欧美韩国一区三区| 中文字幕不卡在线观看| 欧美精品一二三| 成人a级免费电影| 免费日本视频一区| 亚洲五月六月丁香激情| 欧美不卡一区二区| 欧美色图天堂网| 国产综合色在线视频区| 亚洲精品视频观看| 国产亚洲自拍一区| 91精品国产综合久久精品app| 91精品福利视频| 久久久久久免费| 色婷婷av一区二区三区之一色屋| 精品电影一区二区| 久久精品噜噜噜成人av农村| 精品国产在天天线2019| 中文字幕日韩精品一区| 国产精品一卡二| 久久噜噜亚洲综合| 欧美日韩久久不卡| 94-欧美-setu| 一区二区三区精品视频| 欧美国产精品一区二区三区| 欧美亚洲国产一区在线观看网站| 亚洲gay无套男同| voyeur盗摄精品| 一区二区三区资源| 欧美一级高清片| 精品无人码麻豆乱码1区2区| 欧美大片顶级少妇| 丁香婷婷综合色啪| 亚洲成人7777| 亚洲色图视频网站| 中文字幕亚洲在| av电影一区二区| 亚洲成在线观看| 2014亚洲片线观看视频免费| 成人手机在线视频| 欧美国产激情二区三区 | 久久久99久久精品欧美| 韩国在线一区二区| 国产视频一区二区在线| 日韩免费视频一区二区| 欧美日韩高清在线| 成人av电影免费在线播放| 亚洲国产综合91精品麻豆| 成人免费在线播放视频| 精品美女一区二区| 欧美伦理电影网| 成人小视频在线| 成人小视频在线| 欧美日本韩国一区| 91免费看`日韩一区二区| 欧美一级xxx| 欧美成人a视频| 中日韩av电影| 中文字幕的久久| 久久久久久夜精品精品免费| 久久综合九色综合欧美98| 欧美精品一区二区三区蜜桃| 欧美tk—视频vk| 国产色综合一区| 欧美国产视频在线| 亚洲精品国产高清久久伦理二区| 亚洲免费色视频| 亚洲电影一级黄| 日本特黄久久久高潮| 国产一区二区三区久久久| jvid福利写真一区二区三区| 91视频你懂的| 欧美日韩国产a| 精品伦理精品一区| 日韩毛片高清在线播放| 亚洲成人黄色影院| 国产乱子轮精品视频| 成人在线视频首页| 欧美日韩三级在线| 国产日韩影视精品| 亚洲综合激情网| 久久99最新地址| 99久久免费视频.com| 欧美男同性恋视频网站| 日韩欧美国产综合| 亚洲欧美一区二区三区久本道91| 亚洲电影一区二区| 国产精品911| 欧美熟乱第一页| 国产亚洲综合av| 日本美女视频一区二区| 成人午夜视频免费看| 欧美性受xxxx| 国产精品剧情在线亚洲| 日本女优在线视频一区二区| 成人免费高清视频在线观看| 欧美日韩大陆在线| 国产精品国产自产拍高清av | 91国在线观看| 欧美成人乱码一区二区三区| 亚洲男人的天堂av| 韩日欧美一区二区三区| 欧美性感一类影片在线播放| 亚洲精品一区二区三区福利 | 久久精品欧美一区二区三区麻豆| 一区二区三区色| 高清国产午夜精品久久久久久| 欧美日本高清视频在线观看| 国产精品女主播av| 国产一区不卡视频| 91精品国产综合久久小美女| 亚洲日本青草视频在线怡红院| 精品在线你懂的| 在线电影国产精品| 亚洲成人免费视| 91在线国产福利| 日本一区二区电影| 国产一区二区三区观看| 欧美一区二区三区四区在线观看 | 日韩欧美国产小视频| 一区二区三区91| 色综合天天综合网国产成人综合天| 久久精品一区蜜桃臀影院| 久久se这里有精品| 日韩一级免费一区| 六月丁香婷婷色狠狠久久| 5858s免费视频成人|