1.RTX_lib.c-74行
void *os_active_TCB[OS_TASKCNT];//活动任务队列指针
+------------+
| P_TCB 0 | = NULL
| P_TCB 1 | = NULL
| P_TCB 2 | = NULL
| P_TCB . | = NULL
| P_TCB . | = NULL
| P_TCB . | = NULL
| P_TCB n | = NULL
+------------+
n = OS_TASKCNT - 1
void类型的指针指向在活的任务TCB
2.RTX_lib.c-58行
U32 mp_tcb[(((OS_TCB_SIZE)+3)/4)*(OS_TASKCNT) + 3]//任务控制块内存池,4字节对齐
3.RTX_lib.c-62行
#define _declare_box8(pool,size,cnt) U64 pool[(((size)+7)/8)*(cnt) + 2]
_declare_box8 (mp_stk, OS_STKSIZE*4, OS_TASKCNT-OS_PRIVCNT+1);
展开后:
U64 mp_stk[(((OS_STKSIZE*4)+7)/8)*(OS_TASKCNT-OS_PRIVCNT+1) + 2]//系统任务栈内存池
4.RTX_lib.c-82行
U32 const *m_tmr = NULL;//定时器
+-------------------+
| U16 *m_tmr |
+-------------------+
5.rt_Task.c-29行
struct OS_TCB os_idle_TCB; //空闲任务TCB
+-------------------+
| U8 cb_type | = TCB
| U8 state | = READY -> = RUNING
| U8 prio | = 0
| U8 task_id | = 255-
| OS_TCB * p_lnk | = NULL
| OS_TCB * p_rlnk | = NULL
| OS_TCB * p_dlnk | = NULL
| OS_TCB * p_plnk | = NULL
| U16 delta_time | = 0
| U16 interval_time| = 0
| u16 events | = 0
| U16 waits | = 0
| void ** msg | =
| U8 ret_val | = OS_R_OK
| U8 ret_upd | = 0
| U16 priv_stack | = 0-
| U32 tsk_stack | =
| U32 * stack | = rt_alloc_box (mp_stk);
| FUNCP ptask | = os_idle_demon
+-------------------+
os_idle_TCB.task_id = 255;
os_idle_TCB.priv_stack = 0;
rt_init_context (&os_idle_TCB, 0, os_idle_demon);
void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body) {
/* Initialize general part of the Task Control Block. */
p_TCB->cb_type = TCB;
p_TCB->state = READY;
p_TCB->prio = priority;
p_TCB->p_lnk = NULL;
p_TCB->p_rlnk = NULL;
p_TCB->p_dlnk = NULL;
p_TCB->p_blnk = NULL;
p_TCB->delta_time = 0;
p_TCB->interval_time = 0;
p_TCB->events = 0;
p_TCB->waits = 0;
p_TCB->ret_val = OS_R_OK;
p_TCB->ret_upd = 0;
if (p_TCB->priv_stack == 0) {
/* Allocate the memory space for the stack. */
p_TCB->stack = rt_alloc_box (mp_stk);
}
rt_init_stack (p_TCB, task_body);
}
6.rt_Liat.c-25行
struct OS_XCB os_rdy;//就绪任务列表表头
+-------------------+
| U8 cb_type | = HCB
| OS_TCB * p_lnk | = NULL
| OS_TCB * p_rlnk |
| OS_TCB * p_dlnk |
| OS_TCB * p_plnk |
| U16 delta_time |
+-------------------+
7.rt_Liat.c-27行
struct OS_XCB os_dly;//延时任务列表表头
+-------------------+
| U8 cb_type | = HCB
| OS_TCB * p_lnk |
| OS_TCB * p_rlnk |
| OS_TCB * p_dlnk | = NULL
| OS_TCB * p_plnk | = NULL
| U16 delta_time | = 0
+-------------------+
8.rt_Task-26行
struct OS_TSK os_tsk;//正在运行的任务
+-------------------+
| P_TCB run | = &os_idle_TCB
| P_TCB new |
+-------------------+
9.RTX_lib
U32 os_fifo[OS_FIFOSZ*2+1];//ISR请求队列
+-------------------+
| U8 first |
| U8 last |
| U8 count |
| U8 count |
| +--------------+ |
| | void * id | |
| | U32 arg | |
| +--------------+ |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+-------------------+
10.rt_Robin.c-23行
struct OS_ROBIN os_robin; //轮调度变量
+-------------------+
| P_TCB task | = NULL
| U16 time |
| U16 tout | = os_rrobin
+-------------------+
|