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 <kumar.gala@intel.com>
This commit is contained in:
parent
6aa67666c4
commit
7fff3de993
|
@ -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
|
||||
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
|
||||
if (arch_num_cpus() > 1) {
|
||||
k_thread_cpu_pin(&threadB_data, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
k_thread_start(&threadA_data);
|
||||
|
|
Loading…
Reference in a new issue