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.
pull/1753/head
Jaeden Amero 2016-04-14 14:26:06 +01:00 committed by Milosch Meriac
parent 58336594ac
commit 829ca3333b
1 changed files with 4 additions and 0 deletions

View File

@ -406,6 +406,10 @@ void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) {
os_tsk.run = &os_idle_TCB; os_tsk.run = &os_idle_TCB;
os_tsk.run->state = RUNNING; os_tsk.run->state = RUNNING;
/* Set the current thread to idle, so that on exit from this SVCall we do not
* de-reference a NULL TCB. */
rt_switch_req(&os_idle_TCB);
/* Initialize ps queue */ /* Initialize ps queue */
os_psq->first = 0U; os_psq->first = 0U;
os_psq->last = 0U; os_psq->last = 0U;