SMP: Idle thread must be assigned to a CPU

This commit is contained in:
Gregory Nutt 2016-02-11 08:01:09 -06:00
parent 89bea6917c
commit 0a7e136a5a

View File

@ -46,14 +46,11 @@
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
# 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 (; ; )
{