[PATCH 1/5] Separate task mode checks

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jan 8 08:59:31 UTC 2019


---
 cpukit/rtems/src/taskmode.c         | 30 +++++++++++++++---------------
 cpukit/score/src/threadinitialize.c | 19 +++++++++++--------
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c
index 7f26bff14e..3e7ebe9d20 100644
--- a/cpukit/rtems/src/taskmode.c
+++ b/cpukit/rtems/src/taskmode.c
@@ -43,22 +43,22 @@ rtems_status_code rtems_task_mode(
   if ( !previous_mode_set )
     return RTEMS_INVALID_ADDRESS;
 
-#if defined( RTEMS_SMP )
-  /*
-   * When in SMP, you cannot disable preemption for a thread or 
-   * alter its interrupt level. It must be fully preemptible with
-   * all interrupts enabled.
-   */
-  if ( rtems_configuration_is_smp_enabled() ) {
-    if ( mask & RTEMS_PREEMPT_MASK ) {
-      if ( !_Modes_Is_preempt( mode_set ) ) {
-        return RTEMS_NOT_IMPLEMENTED;
-      }
-    }
+#if defined(RTEMS_SMP)
+  if (
+    ( mask & RTEMS_PREEMPT_MASK ) != 0
+      && !_Modes_Is_preempt( mode_set )
+      && rtems_configuration_is_smp_enabled()
+  ) {
+    return RTEMS_NOT_IMPLEMENTED;
+  }
+#endif
 
-    if ( mask & RTEMS_INTERRUPT_MASK ) {
-      return RTEMS_NOT_IMPLEMENTED;
-    }
+#if defined(RTEMS_SMP)
+  if (
+    ( mask & RTEMS_INTERRUPT_MASK ) != 0
+      && rtems_configuration_is_smp_enabled()
+  ) {
+    return RTEMS_NOT_IMPLEMENTED;
   }
 #endif
 
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index c15731f99c..2ad4ccd9ed 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -58,15 +58,18 @@ bool _Thread_Initialize(
   size_t                   scheduler_index;
   Per_CPU_Control         *cpu = _Per_CPU_Get_by_index( 0 );
 
-#if defined( RTEMS_SMP )
-  if ( rtems_configuration_is_smp_enabled() ) {
-    if ( !is_preemptible ) {
-      return false;
-    }
+#if defined(RTEMS_SMP)
+  if ( !is_preemptible && rtems_configuration_is_smp_enabled() ) {
+    return false;
+  }
+#endif
 
-    if ( isr_level != 0 ) {
-      return false;
-    }
+#if defined(RTEMS_SMP)
+  if (
+    isr_level != 0
+      && rtems_configuration_is_smp_enabled()
+  ) {
+    return false;
   }
 #endif
 
-- 
2.16.4




More information about the devel mailing list