nu-lb-nuc140 RTX 流程 分析(六)
preempt : 搶佔
每個任務都有4種狀態:分別是:
- 執行態,
- 就緒態,
- 等待態,
- 不活動態
來自<RL-ARM 實時庫使用者指南.chm>
next_TCB->state = READY;
rt_put_prio (&os_rdy, next_TCB);
重點研究一下 ,其中的 優先順序 連結串列 list
rt_init_context (&os_idle_TCB, 0, os_idle_demon);
os_idle_demon任務的優先順序為0
init任務的優先順序為1
phaseA任務的優先順序為1
rt_free_box (mp_tcb, os_tsk.run);
struct OS_TSK os_tsk;
typedef struct OS_TSK {
P_TCB run; /* Current running task /
P_TCB new; / Scheduled task to run */
} *P_TSK;
int rt_free_box (void *box_mem, void *box)
參考:nu-lb-nuc140 RTX 流程 分析(二)
os_evt_wait_and (0x0001, 0xffff);
#define os_evt_wait_and(wflags,tmo) _os_evt_wait((U32)rt_evt_wait,wflags,tmo,__TRUE)
extern OS_RESULT _os_evt_wait(U32 p, U16 wait_flags, U16 timeout,
BOOL and_wait) __SVC_0;
OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait)
rt_evt_wait(0x0001, 0xffff,__TRUE)
rt_system.c
/--------------------------- rt_systick ------------------------------------/
void rt_systick (void) {
/* Check for system clock update, suspend running task. */
P_TCB next;
os_tsk.run->state = READY;
rt_put_rdy_first (os_tsk.run);
/* Check Round Robin timeout. */
rt_chk_robin ();
/* Update delays. */
os_time++;
rt_dec_dly ();
/* Check the user timers. */
rt_tmr_tick ();
/* Switch back to highest ready task */
next = rt_get_first (&os_rdy);
rt_switch_req (next);
}
os_dly 解析
struct OS_XCB os_dly;
(稍後補充)