[rtems commit] score: Add _SMP_Need_inter_processor_interrupts()

Sebastian Huber sebh at rtems.org
Tue Feb 25 11:32:19 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sat Feb 15 11:09:16 2020 +0100

score: Add _SMP_Need_inter_processor_interrupts()

Test for the proper system condition instead of using the
rtems_configuration_is_smp_enabled() workaround.

Update #3876.

---

 cpukit/include/rtems/score/smpimpl.h | 15 +++++++++++++++
 cpukit/rtems/src/taskmode.c          |  3 ++-
 cpukit/score/src/threaddispatch.c    |  2 +-
 cpukit/score/src/threadinitialize.c  |  2 +-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h
index 889ef5b..dbca09d 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -324,6 +324,21 @@ RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void )
 #endif
 }
 
+/**
+ * @brief Indicate if inter-processor interrupts are needed.
+ *
+ * @return True if inter-processor interrupts are needed for the correct system
+ * operation, otherwise false.
+ */
+RTEMS_INLINE_ROUTINE const bool _SMP_Need_inter_processor_interrupts( void )
+{
+  /*
+   * Use the configured processor maximum instead of the actual to allow
+   * testing on uni-processor systems.
+   */
+  return _SMP_Processor_configured_maximum > 1;
+}
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c
index 906f86b..8830f6b 100644
--- a/cpukit/rtems/src/taskmode.c
+++ b/cpukit/rtems/src/taskmode.c
@@ -23,6 +23,7 @@
 #include <rtems/rtems/modesimpl.h>
 #include <rtems/rtems/signalimpl.h>
 #include <rtems/score/schedulerimpl.h>
+#include <rtems/score/smpimpl.h>
 #include <rtems/score/threadimpl.h>
 #include <rtems/config.h>
 
@@ -58,7 +59,7 @@ rtems_status_code rtems_task_mode(
     ( mask & RTEMS_INTERRUPT_MASK ) != 0
       && _Modes_Get_interrupt_level( mode_set ) != 0
 #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
-      && rtems_configuration_is_smp_enabled()
+      && _SMP_Need_inter_processor_interrupts()
 #endif
   ) {
     return RTEMS_NOT_IMPLEMENTED;
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index 65951cc..cd32f5a 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -265,7 +265,7 @@ void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level )
   if (
     !_ISR_Is_enabled( level )
 #if defined(RTEMS_SMP) && CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
-      && rtems_configuration_is_smp_enabled()
+      && _SMP_Need_inter_processor_interrupts()
 #endif
   ) {
     _Internal_error( INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT );
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 4dc6d51..976c977 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -72,7 +72,7 @@ bool _Thread_Initialize(
   if (
     config->isr_level != 0
 #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
-      && rtems_configuration_is_smp_enabled()
+      && _SMP_Need_inter_processor_interrupts()
 #endif
   ) {
     goto failed;



More information about the vc mailing list