[PATCH] score: Critical section change in _Thread_Dispatch

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jul 26 14:40:23 UTC 2013


If we enter _Thread_Dispatch() then _Thread_Dispatch_disable_level must
be zero.  Single processor RTEMS assumes that stores of non-zero values
to _Thread_Dispatch_disable_level are observed by interrupts as non-zero values.

Move the _Thread_Dispatch_set_disable_level( 1 ) out of the first ISR
disabled critical section.  In case interrupts happen between the
_Thread_Dispatch_set_disable_level( 1 ) and _ISR_Disable( level ) then
the interrupt will observe a non-zero _Thread_Dispatch_disable_level and
will not issue a _Thread_Dispatch() and we can enter the ISR disabled
section directly after interrupt processing.

This change leads to symmetry between the single processor and SMP
configuration.
---
 cpukit/score/src/threaddispatch.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index d736b36..c5d0a21 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -65,6 +65,8 @@ void _Thread_Dispatch( void )
      * once someone calls _Thread_Dispatch().
      */
     _Thread_Disable_dispatch();
+  #else
+    _Thread_Dispatch_set_disable_level( 1 );
   #endif
 
   /*
@@ -77,8 +79,6 @@ void _Thread_Dispatch( void )
     #if defined(RTEMS_SMP)
       executing->is_executing = false;
       heir->is_executing = true;
-    #else
-      _Thread_Dispatch_set_disable_level( 1 );
     #endif
     _Thread_Dispatch_necessary = false;
     _Thread_Executing = heir;
-- 
1.7.7




More information about the devel mailing list