[rtems commit] score: Ensure only one CPU if required

Sebastian Huber sebh at rtems.org
Tue Sep 21 08:25:31 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 17 08:49:56 2021 +0200

score: Ensure only one CPU if required

Issue the new fatal SMP error
SMP_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR if the system starts
with not exactly one processor and an uniprocessor scheduler is
configured.

---

 cpukit/include/rtems/score/smpimpl.h                 |  3 ++-
 cpukit/include/rtems/sysinit.h                       |  1 +
 cpukit/score/src/schedulerdefaultpinunpindonothing.c | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h
index 7c3e777..e259105 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -72,7 +72,8 @@ typedef enum {
   SMP_FATAL_SHUTDOWN_RESPONSE,
   SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED,
   SMP_FATAL_SCHEDULER_PIN_OR_UNPIN_NOT_SUPPORTED,
-  SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS
+  SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS,
+  SMP_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR
 } SMP_Fatal_code;
 
 /**
diff --git a/cpukit/include/rtems/sysinit.h b/cpukit/include/rtems/sysinit.h
index 3e85aa9..e3d7023 100644
--- a/cpukit/include/rtems/sysinit.h
+++ b/cpukit/include/rtems/sysinit.h
@@ -43,6 +43,7 @@ extern "C" {
 #define RTEMS_SYSINIT_INITIAL_EXTENSIONS         000500
 #define RTEMS_SYSINIT_MP_EARLY                   000600
 #define RTEMS_SYSINIT_DATA_STRUCTURES            000700
+#define RTEMS_SYSINIT_SCHEDULER                  000780
 #define RTEMS_SYSINIT_MP                         000800
 #define RTEMS_SYSINIT_USER_EXTENSIONS            000900
 #define RTEMS_SYSINIT_CLASSIC_TASKS              000a00
diff --git a/cpukit/score/src/schedulerdefaultpinunpindonothing.c b/cpukit/score/src/schedulerdefaultpinunpindonothing.c
index f7bab4f..f3ecb0b 100644
--- a/cpukit/score/src/schedulerdefaultpinunpindonothing.c
+++ b/cpukit/score/src/schedulerdefaultpinunpindonothing.c
@@ -39,6 +39,9 @@
 #endif
 
 #include <rtems/score/scheduler.h>
+#include <rtems/score/interr.h>
+#include <rtems/score/smpimpl.h>
+#include <rtems/sysinit.h>
 
 void _Scheduler_default_Pin_or_unpin_do_nothing(
   const Scheduler_Control *scheduler,
@@ -52,3 +55,19 @@ void _Scheduler_default_Pin_or_unpin_do_nothing(
   (void) node;
   (void) cpu;
 }
+
+static void _Scheduler_Ensure_exactly_one_processor( void )
+{
+  if ( _SMP_Get_processor_maximum() != 1 ) {
+    _Terminate(
+      RTEMS_FATAL_SOURCE_SMP,
+      SMP_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR
+    );
+  }
+}
+
+RTEMS_SYSINIT_ITEM(
+  _Scheduler_Ensure_exactly_one_processor,
+  RTEMS_SYSINIT_SCHEDULER,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);



More information about the vc mailing list