diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-04-15 16:20:17 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-04-16 09:07:33 +0200 |
commit | 33d0666d02832f63dfd035c7ac9890b4397a1fdc (patch) | |
tree | c963937feb2dce85acaa27cb4663bb05fc1fbd43 /cpukit/score/src/threaddispatch.c | |
parent | bsp/qoriq: SMP support for IRQ support (diff) | |
download | rtems-33d0666d02832f63dfd035c7ac9890b4397a1fdc.tar.bz2 |
score: Critical fix for SMP
The _Scheduler_SMP_Allocate_processor() and _Thread_Dispatch() exchange
information without locks. Make sure we use the right load/store
ordering.
Diffstat (limited to 'cpukit/score/src/threaddispatch.c')
-rw-r--r-- | cpukit/score/src/threaddispatch.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c index 40a2efbb82..9e3f86e23b 100644 --- a/cpukit/score/src/threaddispatch.c +++ b/cpukit/score/src/threaddispatch.c @@ -97,9 +97,20 @@ void _Thread_Dispatch( void ) #else while ( per_cpu->dispatch_necessary ) { #endif - heir = per_cpu->heir; per_cpu->dispatch_necessary = false; + +#if defined( RTEMS_SMP ) + /* + * It is critical that we first update the dispatch necessary and then the + * read the heir so that we don't miss an update by + * _Scheduler_SMP_Allocate_processor(). + */ + _Atomic_Fence( ATOMIC_ORDER_SEQ_CST ); +#endif + + heir = per_cpu->heir; per_cpu->executing = heir; + #if defined( RTEMS_SMP ) executing->is_executing = false; heir->is_executing = true; |