You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/05/04 12:30:42 UTC

[nuttx] branch master updated: sched: add the CPU bitset to initialize the non-exclusive CPU

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new f7cfcd4e95 sched: add the CPU bitset to initialize the non-exclusive CPU
f7cfcd4e95 is described below

commit f7cfcd4e9585415021bcd92952084bb0b65ea199
Author: zhangyuan21 <zh...@xiaomi.com>
AuthorDate: Wed Apr 19 11:00:57 2023 +0800

    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 <zh...@xiaomi.com>
---
 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);