[rtems commit] smp: Fix _Thread_Dispatch_decrement_disable_level
Sebastian Huber
sebh at rtems.org
Wed Jun 12 14:08:10 UTC 2013
Module: rtems
Branch: master
Commit: aabfcd0c3330830356a55782e2bdc99e3979165a
Changeset: http://git.rtems.org/rtems/commit/?id=aabfcd0c3330830356a55782e2bdc99e3979165a
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jun 12 15:11:57 2013 +0200
smp: Fix _Thread_Dispatch_decrement_disable_level
We must obtain the processor ID after interrupts are disabled since a
non-optimizing compiler may store the value on the stack and read it
back.
---
cpukit/score/src/threaddispatchdisablelevel.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c
index 4686795..154a6af 100644
--- a/cpukit/score/src/threaddispatchdisablelevel.c
+++ b/cpukit/score/src/threaddispatchdisablelevel.c
@@ -56,12 +56,18 @@ uint32_t _Thread_Dispatch_increment_disable_level( void )
{
Thread_Dispatch_disable_level_lock_control *level_lock =
&_Thread_Dispatch_disable_level_lock;
- int self_cpu = bsp_smp_processor_id();
+ int self_cpu;
ISR_Level isr_level;
uint32_t disable_level;
_ISR_Disable_on_this_core( isr_level );
+ /*
+ * We must obtain the processor ID after interrupts are disabled since a
+ * non-optimizing compiler may store the value on the stack and read it back.
+ */
+ self_cpu = bsp_smp_processor_id();
+
if ( level_lock->owner_cpu != self_cpu ) {
_SMP_lock_Acquire( &level_lock->lock );
level_lock->owner_cpu = self_cpu;
More information about the vc
mailing list