[rtems commit] score: Fix set scheduler
Sebastian Huber
sebh at rtems.org
Mon Jul 10 07:39:45 UTC 2017
Module: rtems
Branch: master
Commit: 4a1bdd3045fa00c95924deb27bc0ffab7e8aaf14
Changeset: http://git.rtems.org/rtems/commit/?id=4a1bdd3045fa00c95924deb27bc0ffab7e8aaf14
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Jul 7 08:30:20 2017 +0200
score: Fix set scheduler
Ensure that the thread processor affinity fits the new scheduler
instance.
Update #3059.
---
cpukit/score/include/rtems/score/schedulerimpl.h | 18 +++++++++++++-----
testsuites/smptests/smpscheduler02/init.c | 16 ++++++++++------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index cb9fd7e..85fcace 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -1092,10 +1092,22 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
}
old_scheduler = _Thread_Scheduler_get_home( the_thread );
+ new_scheduler_node = _Thread_Scheduler_get_node_by_index(
+ the_thread,
+ _Scheduler_Get_index( new_scheduler )
+ );
_Scheduler_Acquire_critical( new_scheduler, &lock_context );
- if ( _Scheduler_Get_processor_count( new_scheduler ) == 0 ) {
+ if (
+ _Scheduler_Get_processor_count( new_scheduler ) == 0
+ || !( *new_scheduler->Operations.set_affinity )(
+ new_scheduler,
+ the_thread,
+ new_scheduler_node,
+ &the_thread->Scheduler.Affinity
+ )
+ ) {
_Scheduler_Release_critical( new_scheduler, &lock_context );
_Priority_Plain_insert(
&old_scheduler_node->Wait.Priority,
@@ -1110,10 +1122,6 @@ RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
_Scheduler_Release_critical( new_scheduler, &lock_context );
_Thread_Scheduler_process_requests( the_thread );
- new_scheduler_node = _Thread_Scheduler_get_node_by_index(
- the_thread,
- _Scheduler_Get_index( new_scheduler )
- );
#else
new_scheduler_node = old_scheduler_node;
#endif
diff --git a/testsuites/smptests/smpscheduler02/init.c b/testsuites/smptests/smpscheduler02/init.c
index a15218b..7dd60ec 100644
--- a/testsuites/smptests/smpscheduler02/init.c
+++ b/testsuites/smptests/smpscheduler02/init.c
@@ -47,7 +47,7 @@ static void task(rtems_task_argument arg)
rtems_test_assert(rtems_get_current_processor() == 1);
rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1);
- rtems_test_assert(sched_get_priority_max(SCHED_RR) == 126);
+ rtems_test_assert(sched_get_priority_max(SCHED_RR) == INT_MAX - 1);
sc = rtems_semaphore_obtain(cmtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
rtems_test_assert(sc == RTEMS_NOT_DEFINED);
@@ -345,12 +345,15 @@ static void test(void)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
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_set_affinity(task_id, sizeof(second_cpu), &second_cpu);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_set_scheduler(task_id, scheduler_a_id, 1);
+ rtems_test_assert(sc == RTEMS_UNSATISFIED);
+
sc = rtems_task_get_scheduler(task_id, &scheduler_id);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
rtems_test_assert(scheduler_id == scheduler_b_id);
@@ -415,6 +418,7 @@ static void Init(rtems_task_argument arg)
/* Lets see when the first RTEMS system hits this limit */
#define CONFIGURE_MAXIMUM_PROCESSORS 64
+#define CONFIGURE_SCHEDULER_EDF_SMP
#define CONFIGURE_SCHEDULER_PRIORITY_SMP
#define CONFIGURE_SCHEDULER_SIMPLE_SMP
@@ -422,13 +426,13 @@ static void Init(rtems_task_argument arg)
RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(a, 256);
-RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(b, 128);
+RTEMS_SCHEDULER_CONTEXT_EDF_SMP(b, CONFIGURE_MAXIMUM_PROCESSORS);
RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP(c);
#define CONFIGURE_SCHEDULER_CONTROLS \
RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(a, SCHED_A), \
- RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(b, SCHED_B), \
+ RTEMS_SCHEDULER_CONTROL_EDF_SMP(b, SCHED_B), \
RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP(c, SCHED_C)
#define CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS \
More information about the vc
mailing list