From f7cfcd4e9585415021bcd92952084bb0b65ea199 Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Wed, 19 Apr 2023 11:00:57 +0800 Subject: [PATCH] sched: add the CPU bitset to initialize the non-exclusive CPU Set the Default CPU bits. The way to use the unset CPU is to call the sched_setaffinity function to bind a task to the CPU. bit0 means CPU0. Signed-off-by: zhangyuan21 --- sched/Kconfig | 7 +++++++ sched/init/nx_start.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sched/Kconfig b/sched/Kconfig index ce5ed8efcf..e3d2f9d71e 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -358,6 +358,13 @@ config SMP_NCPUS SMP configuration. However, running the SMP logic in a single CPU configuration is useful during certain testing. +config SMP_DEFAULT_CPUSET + hex "Default CPU bit set" + default 0xffffffff + ---help--- + Set the Default CPU bits. The way to use the unset CPU is to call the + sched_setaffinity function to bind a task to the CPU. bit0 means CPU0. + endif # SMP choice diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 8262eb6c43..df74373a0a 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -376,7 +376,8 @@ void nx_start(void) * the IDLE task. */ - g_idletcb[i].cmn.affinity = SCHED_ALL_CPUS; + g_idletcb[i].cmn.affinity = + (cpu_set_t)(CONFIG_SMP_DEFAULT_CPUSET & SCHED_ALL_CPUS); #else g_idletcb[i].cmn.flags = (TCB_FLAG_TTYPE_KERNEL | TCB_FLAG_NONCANCELABLE);