Skip to content

Commit 829ca33

Browse files
Patatermeriac
authored andcommitted
RTX: Actively switch to the idle thread
Prevent a switch to a NULL target thread by setting the new task to run to be the idle task. Otherwise, we get nasty usage fault because we would be returning from the rt_sys_init SVC with a PSP of 0x20.
1 parent 5833659 commit 829ca33

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rtos/rtx/TARGET_CORTEX_M/rt_Task.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) {
406406
os_tsk.run = &os_idle_TCB;
407407
os_tsk.run->state = RUNNING;
408408

409+
/* Set the current thread to idle, so that on exit from this SVCall we do not
410+
* de-reference a NULL TCB. */
411+
rt_switch_req(&os_idle_TCB);
412+
409413
/* Initialize ps queue */
410414
os_psq->first = 0U;
411415
os_psq->last = 0U;

0 commit comments

Comments
 (0)