[rtems commit] score: Fix default set affinity

Sebastian Huber sebh at rtems.org
Mon Jul 10 07:38:46 UTC 2017


Module:    rtems
Branch:    master
Commit:    16347a6b3910b04932225f1ea296a7adf206ec9e
Changeset: http://git.rtems.org/rtems/commit/?id=16347a6b3910b04932225f1ea296a7adf206ec9e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jul  7 07:36:52 2017 +0200

score: Fix default set affinity

The set of online processors must be a subset of the thread processor
affinity for the schedulers without arbitrary processor affinity support
to avoid problems in case of processor addition and removal.

Update #3059.

---

 cpukit/score/include/rtems/score/schedulerimpl.h | 7 +++----
 testsuites/smptests/smpscheduler02/init.c        | 7 ++++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 6f220ac..49aaf02 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -612,10 +612,9 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body(
   const Processor_mask    *affinity
 )
 {
-  return _Processor_mask_Is_subset(
-    affinity,
-    _Scheduler_Get_processors( scheduler )
-  );
+  (void) scheduler;
+  (void) the_thread;
+  return _Processor_mask_Is_subset( affinity, _SMP_Get_online_processors() );
 }
 
 bool _Scheduler_Set_affinity(
diff --git a/testsuites/smptests/smpscheduler02/init.c b/testsuites/smptests/smpscheduler02/init.c
index db7d863..a15218b 100644
--- a/testsuites/smptests/smpscheduler02/init.c
+++ b/testsuites/smptests/smpscheduler02/init.c
@@ -223,9 +223,7 @@ static void test(void)
   CPU_ZERO(&second_cpu);
   CPU_SET(1, &second_cpu);
 
-  CPU_ZERO(&all_cpus);
-  CPU_SET(0, &all_cpus);
-  CPU_SET(1, &all_cpus);
+  CPU_FILL(&all_cpus);
 
   CPU_ZERO(&online_cpus);
   CPU_SET(0, &online_cpus);
@@ -348,6 +346,9 @@ static void test(void)
     rtems_test_assert(scheduler_id == scheduler_b_id);
 
     sc = rtems_task_set_affinity(task_id, sizeof(second_cpu), &second_cpu);
+    rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
+
+    sc = rtems_task_set_affinity(task_id, sizeof(online_cpus), &online_cpus);
     rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
     sc = rtems_task_get_scheduler(task_id, &scheduler_id);



More information about the vc mailing list