From ddbc94889509be9a9dfdb422f2da4bfd2f122834 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 11 Feb 2016 12:18:54 -0600 Subject: [PATCH] SMP: Minor SMP-related clean-up/improvements --- arch | 2 +- configs | 2 +- sched/Kconfig | 9 +++++++++ sched/init/os_smpstart.c | 21 ++------------------- sched/init/os_start.c | 18 ++++++------------ 5 files changed, 19 insertions(+), 33 deletions(-) diff --git a/arch b/arch index 7451a16948..cf3c8382fa 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 7451a16948db82ad2a75723df73160357d816577 +Subproject commit cf3c8382fa36d28b1f153536368cfb07adfbb286 diff --git a/configs b/configs index 81a10b64ed..600d77e8b4 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit 81a10b64ed544684bb975e218e09ab5bc8aaf445 +Subproject commit 600d77e8b4631a67a6099b35a6959b6099b4a42b diff --git a/sched/Kconfig b/sched/Kconfig index 5a31c6727d..c30b672b1d 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -256,6 +256,15 @@ config SMP_NCPUS This value identifies the number of CPUs support by the processor that will be used for SMP. +config SMP_IDLETHREAD_STACKSIZE + int "CPU IDLE stack size" + default 2048 + ---help--- + Each CPU will have its own IDLE stack. System initialization occurs + on CPU0 and uses CONFIG_IDLETHREAD_STACKSIZE which will probably be + larger than is generally needed. This setting provides the STACK + size for the IDLE task on CPUS 1 through (CONFIG_SMP_NCPUS-1). + endif # SMP choice diff --git a/sched/init/os_smpstart.c b/sched/init/os_smpstart.c index bfbc49d509..351e90324a 100644 --- a/sched/init/os_smpstart.c +++ b/sched/init/os_smpstart.c @@ -40,14 +40,12 @@ #include #include -#include #include #include #include -# include "sched/sched.h" -# include "init/init.h" +#include "init/init.h" #ifdef CONFIG_SMP @@ -72,22 +70,7 @@ 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 */ + /* Enter the IDLE loop */ sdbg("CPU%d: Beginning Idle Loop\n"); for (; ; ) diff --git a/sched/init/os_start.c b/sched/init/os_start.c index 95fd9526c9..c0caabc8f7 100644 --- a/sched/init/os_start.c +++ b/sched/init/os_start.c @@ -300,20 +300,16 @@ uint8_t g_os_initstate; /* See enum os_initstate_e */ * initialization task is responsible for bringing up the rest of the system. */ -static FAR struct task_tcb_s g_idletcb; +static struct task_tcb_s g_idletcb; /* This is the name of the idle task */ -static FAR const char g_idlename[] = "Idle Task"; +static const char g_idlename[] = "Idle Task"; /* This the IDLE idle threads argument list. */ static FAR char *g_idleargv[2]; -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -336,6 +332,7 @@ static FAR char *g_idleargv[2]; void os_start(void) { + FAR dq_queue_t *tasklist; int i; slldbg("Entry\n"); @@ -438,14 +435,11 @@ void os_start(void) /* Then add the idle task's TCB to the head of the ready to run list */ #ifdef CONFIG_SMP - /* Use the list a ready-to-run tasks assigned to CPU0 */ - - dq_addfirst((FAR dq_entry_t *)&g_idletcb, (FAR dq_queue_t *)&g_assignedtasks[0]); + tasklist = TLIST_HEAD(TSTATE_TASK_RUNNING, 0); #else - /* Use the common, unassigned ready-to-run list */ - - dq_addfirst((FAR dq_entry_t *)&g_idletcb, (FAR dq_queue_t *)&g_readytorun); + tasklist = TLIST_HEAD(TSTATE_TASK_RUNNING); #endif + dq_addfirst((FAR dq_entry_t *)&g_idletcb, tasklist); /* Initialize the processor-specific portion of the TCB */