From 7fff3de9931cc524b62e6e9d212d7d7efbe0100a Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 20 Oct 2022 08:39:14 -0500 Subject: [PATCH] samples: synchronization: Convert CONFIG_MP_NUM_CPUS handling Move runtime checks to use arch_num_cpus() and build checks to use CONFIG_MP_MAX_NUM_CPUS. This is to allow runtime determination of the number of CPUs in the future. Signed-off-by: Kumar Gala --- samples/synchronization/src/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/samples/synchronization/src/main.c b/samples/synchronization/src/main.c index 1befc1c89bb..d4afde4ab81 100644 --- a/samples/synchronization/src/main.c +++ b/samples/synchronization/src/main.c @@ -16,9 +16,7 @@ * world application would likely use the static approach for both threads. */ -#define PIN_THREADS (IS_ENABLED(CONFIG_SMP) \ - && IS_ENABLED(CONFIG_SCHED_CPU_MASK) \ - && (CONFIG_MP_NUM_CPUS > 1)) +#define PIN_THREADS (IS_ENABLED(CONFIG_SMP) && IS_ENABLED(CONFIG_SCHED_CPU_MASK)) /* size of stack area used by each thread */ #define STACKSIZE 1024 @@ -113,7 +111,9 @@ void main(void) PRIORITY, 0, K_FOREVER); k_thread_name_set(&threadA_data, "thread_a"); #if PIN_THREADS - k_thread_cpu_pin(&threadA_data, 0); + if (arch_num_cpus() > 1) { + k_thread_cpu_pin(&threadA_data, 0); + } #endif k_thread_create(&threadB_data, threadB_stack_area, @@ -122,7 +122,9 @@ void main(void) PRIORITY, 0, K_FOREVER); k_thread_name_set(&threadB_data, "thread_b"); #if PIN_THREADS - k_thread_cpu_pin(&threadB_data, 1); + if (arch_num_cpus() > 1) { + k_thread_cpu_pin(&threadB_data, 1); + } #endif k_thread_start(&threadA_data);