diff --git a/sched/init/os_smpstart.c b/sched/init/os_smpstart.c index 0bd33ffb8e..bfbc49d509 100644 --- a/sched/init/os_smpstart.c +++ b/sched/init/os_smpstart.c @@ -46,14 +46,11 @@ #include #include +# include "sched/sched.h" # include "init/init.h" #ifdef CONFIG_SMP -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -75,6 +72,23 @@ int os_idletask(int argc, FAR char *argv[]) { + FAR struct tcb_s *rtcb = this_task(); + irqstate_t flags; + int cpu = this_cpu(); + + /* Make sure that this thread is assigned to the current CPU */ + + DEBUGASSERT(rtcb->cpu == cpu); + + /* REVISIT: disabling interrupts is not sufficient protection */ + + flags = irqsave(); + rtcb->flags |= TCB_FLAG_CPU_ASSIGNED; + rtcb->cpu = cpu; + irqrestore(flags); + + /* Then enter the IDLE loop */ + sdbg("CPU%d: Beginning Idle Loop\n"); for (; ; ) {