[PATCH 1/6] smp: Delete RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARY

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 14 14:31:56 UTC 2013


The thread dispatch is a side-effect of interrupt processing, thus there
is no need to send an explicit message.
---
 cpukit/score/include/rtems/score/smp.h |    7 ----
 cpukit/score/src/smp.c                 |   58 +++++++++++++++----------------
 2 files changed, 28 insertions(+), 37 deletions(-)

diff --git a/cpukit/score/include/rtems/score/smp.h b/cpukit/score/include/rtems/score/smp.h
index ea073ac..a015156 100644
--- a/cpukit/score/include/rtems/score/smp.h
+++ b/cpukit/score/include/rtems/score/smp.h
@@ -37,13 +37,6 @@ extern "C" {
 /**
  *  This defines the bit which indicates the interprocessor interrupt
  *  has been requested so that RTEMS will reschedule on this CPU
- *  because the currently executing thread needs to be switched out.
- */
-#define RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARY  0x01
-
-/**
- *  This defines the bit which indicates the interprocessor interrupt
- *  has been requested so that RTEMS will reschedule on this CPU
  *  because the currently executing thread has been sent a signal.
  */
 #define RTEMS_BSP_SMP_SIGNAL_TO_SELF            0x02
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index 3081062..fce9275 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -69,43 +69,41 @@ void rtems_smp_process_interrupt( void )
 {
   int              self = bsp_smp_processor_id();
   Per_CPU_Control *per_cpu = &_Per_CPU_Information[ self ];
-  uint32_t         message;
-  ISR_Level        level;
 
 
-  _Per_CPU_Lock_acquire( per_cpu, level );
-  message = per_cpu->message;
-  per_cpu->message = 0;
-  _Per_CPU_Lock_release( per_cpu, level );
+  if ( per_cpu->message != 0 ) {
+    uint32_t  message;
+    ISR_Level level;
 
-  #if defined(RTEMS_DEBUG)
-    {
-      void *sp = __builtin_frame_address(0);
-      if ( !(message & RTEMS_BSP_SMP_SHUTDOWN) ) {
-        printk( "ISR on CPU %d -- (0x%02x) (0x%p)\n", self, message, sp );
-	if ( message & RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARY )
-	  printk( "context switch necessary\n" );
-	if ( message & RTEMS_BSP_SMP_SIGNAL_TO_SELF )
-	  printk( "signal to self\n" );
-	if ( message & RTEMS_BSP_SMP_SHUTDOWN )
-	  printk( "shutdown\n" );
+    _Per_CPU_Lock_acquire( per_cpu, level );
+    message = per_cpu->message;
+    per_cpu->message = 0;
+    _Per_CPU_Lock_release( per_cpu, level );
+
+    #if defined(RTEMS_DEBUG)
+      {
+        void *sp = __builtin_frame_address(0);
+        if ( !(message & RTEMS_BSP_SMP_SHUTDOWN) ) {
+          printk( "ISR on CPU %d -- (0x%02x) (0x%p)\n", self, message, sp );
+          if ( message & RTEMS_BSP_SMP_SIGNAL_TO_SELF )
+            printk( "signal to self\n" );
+          if ( message & RTEMS_BSP_SMP_SHUTDOWN )
+            printk( "shutdown\n" );
+        }
+        printk( "Dispatch level %d\n", _Thread_Dispatch_get_disable_level() );
       }
- 
-      printk( "Dispatch level %d\n", _Thread_Dispatch_get_disable_level() );
-    }
-  #endif
+    #endif
 
-  if ( message & RTEMS_BSP_SMP_SHUTDOWN ) {
-    _ISR_Disable_on_this_core( level );
+    if ( ( message & RTEMS_BSP_SMP_SHUTDOWN ) != 0 ) {
+      _ISR_Disable_on_this_core( level );
 
-    while ( _Thread_Dispatch_decrement_disable_level() != 0 ) {
-      /* Release completely */
-    }
+      _Thread_Dispatch_set_disable_level( 0 );
 
-    _Per_CPU_Change_state( per_cpu, PER_CPU_STATE_SHUTDOWN );
+      _Per_CPU_Change_state( per_cpu, PER_CPU_STATE_SHUTDOWN );
 
-    _CPU_Fatal_halt( self );
-    /* does not continue past here */
+      _CPU_Fatal_halt( self );
+      /* does not continue past here */
+    }
   }
 }
 
@@ -179,7 +177,7 @@ void _SMP_Request_other_cores_to_dispatch( void )
           && per_cpu->state == PER_CPU_STATE_UP
           && per_cpu->dispatch_necessary
       ) {
-        _SMP_Send_message( cpu, RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARY );
+        _SMP_Send_message( cpu, 0 );
       }
     }
   }
-- 
1.7.7




More information about the devel mailing list