diff options
-rw-r--r-- | 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 4686795bbb..154a6af637 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; |