Skip to content

Commit ac29149

Browse files
committed
Fix missing barrier in TX_DISABLE for Cortex-R5
This commit fixes thread safety issue in tx_byte_allocate by correcting clobber list and adding missing compiler fence. This addresses potential race conditions when aggressive compiler optimization is enabled. Patched by Pat Kusbel. See eclipse-threadx#334
1 parent 0670e81 commit ac29149

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/cortex_r5/gnu/inc/tx_port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ unsigned int _tx_thread_interrupt_restore(UINT old_posture);
287287
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
288288

289289
#ifdef TX_ENABLE_FIQ_SUPPORT
290-
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID if ": "=r" (interrupt_save) );
290+
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID if ": "=r" (interrupt_save) : "memory");
291291
#else
292-
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID i ": "=r" (interrupt_save) );
292+
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID i ": "=r" (interrupt_save) : "memory");
293293
#endif
294294

295295
#define TX_RESTORE asm volatile (" MSR CPSR_c,%0 "::"r" (interrupt_save) );

0 commit comments

Comments
 (0)