zoukankan      html  css  js  c++  java
  • uCOS-II 学习笔记之任务管理--------任务控制块OS_TCB

      任务控制块是任务管理的核心数据结构,操作系统在启动的时候,首先要在内存中创建一定数量的任务控制块。

    以下是OS_TCB的数据结构:

     1 typedef struct os_tcb {
     2     OS_STK          *OSTCBStkPtr;           /* Pointer to current top of stack                         */
     3 
     4 #if OS_TASK_CREATE_EXT_EN > 0u
     5     void            *OSTCBExtPtr;           /* Pointer to user definable data for TCB extension        */
     6     OS_STK          *OSTCBStkBottom;        /* Pointer to bottom of stack                              */
     7     INT32U           OSTCBStkSize;          /* Size of task stack (in number of stack elements)        */
     8     INT16U           OSTCBOpt;              /* Task options as passed by OSTaskCreateExt()             */
     9     INT16U           OSTCBId;               /* Task ID (0..65535)                                      */
    10 #endif
    11 
    12     struct os_tcb   *OSTCBNext;             /* Pointer to next     TCB in the TCB list                 */
    13     struct os_tcb   *OSTCBPrev;             /* Pointer to previous TCB in the TCB list                 */
    14 
    15 #if (OS_EVENT_EN)
    16     OS_EVENT        *OSTCBEventPtr;         /* Pointer to          event control block                 */
    17 #endif
    18 
    19 #if (OS_EVENT_EN) && (OS_EVENT_MULTI_EN > 0u)
    20     OS_EVENT       **OSTCBEventMultiPtr;    /* Pointer to multiple event control blocks                */
    21 #endif
    22 
    23 #if ((OS_Q_EN > 0u) && (OS_MAX_QS > 0u)) || (OS_MBOX_EN > 0u)
    24     void            *OSTCBMsg;              /* Message received from OSMboxPost() or OSQPost()         */
    25 #endif
    26 
    27 #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
    28 #if OS_TASK_DEL_EN > 0u
    29     OS_FLAG_NODE    *OSTCBFlagNode;         /* Pointer to event flag node                              */
    30 #endif
    31     OS_FLAGS         OSTCBFlagsRdy;         /* Event flags that made task ready to run                 */
    32 #endif
    33 
    34     INT32U           OSTCBDly;              /* Nbr ticks to delay task or, timeout waiting for event   */
    35     INT8U            OSTCBStat;             /* Task      status                                        */
    36     INT8U            OSTCBStatPend;         /* Task PEND status                                        */
    37     INT8U            OSTCBPrio;             /* Task priority (0 == highest)                            */
    38 
    39     INT8U            OSTCBX;                /* Bit position in group  corresponding to task priority   */
    40     INT8U            OSTCBY;                /* Index into ready table corresponding to task priority   */
    41     OS_PRIO          OSTCBBitX;             /* Bit mask to access bit position in ready table          */
    42     OS_PRIO          OSTCBBitY;             /* Bit mask to access bit position in ready group          */
    43 
    44 #if OS_TASK_DEL_EN > 0u
    45     INT8U            OSTCBDelReq;           /* Indicates whether a task needs to delete itself         */
    46 #endif
    47 
    48 #if OS_TASK_PROFILE_EN > 0u
    49     INT32U           OSTCBCtxSwCtr;         /* Number of time the task was switched in                 */
    50     INT32U           OSTCBCyclesTot;        /* Total number of clock cycles the task has been running  */
    51     INT32U           OSTCBCyclesStart;      /* Snapshot of cycle counter at start of task resumption   */
    52     OS_STK          *OSTCBStkBase;          /* Pointer to the beginning of the task stack              */
    53     INT32U           OSTCBStkUsed;          /* Number of bytes used from the stack                     */
    54 #endif
    55 
    56 #if OS_TASK_NAME_EN > 0u
    57     INT8U           *OSTCBTaskName;
    58 #endif
    59 
    60 #if OS_TASK_REG_TBL_SIZE > 0u
    61     INT32U           OSTCBRegTbl[OS_TASK_REG_TBL_SIZE];
    62 #endif
    63 } OS_TCB;
  • 相关阅读:
    媒体查询漫谈——@media Queries
    JavaScript工具函数集
    什么是BFC、IFC、GFC和FFC
    HTTP与HTTPS的区别
    reflow 和 repaint
    客户端检测
    ajax
    批量删除
    数据访问
    登录主页面代码
  • 原文地址:https://www.cnblogs.com/xiaofeng6636/p/3512952.html
Copyright © 2011-2022 走看看