From 4e9ee786f611a620e5771556e4a5129d14eb6713 Mon Sep 17 00:00:00 2001 From: Wayne Thornton Date: Fri, 22 May 2026 13:12:17 -0600 Subject: [PATCH] cpukit/score/.../cpu.h: Implement _CPU_Spin_wait() _CPU_Spin_wait() is an assembly function which prevents aggressive speculative execution by the CPU during spin-wait loops. Added benefit is reduction of thermal load. This function is part of the Deterministic Hedged Read Library API. --- cpukit/score/cpu/x86_64/include/rtems/score/cpu.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cpukit/score/cpu/x86_64/include/rtems/score/cpu.h b/cpukit/score/cpu/x86_64/include/rtems/score/cpu.h index 32fb9ea722..372a8ce057 100644 --- a/cpukit/score/cpu/x86_64/include/rtems/score/cpu.h +++ b/cpukit/score/cpu/x86_64/include/rtems/score/cpu.h @@ -443,6 +443,18 @@ CPU_Counter_ticks _CPU_Counter_read( void ); typedef uintptr_t CPU_Uint32ptr; +/** + * Pauses the CPU pipeline to prevent aggressive speculative execution + * and reduce thermal load during spin-wait loops. + */ +static inline void _CPU_Spin_wait( void ) +{ + __asm__ volatile( "pause" ::: "memory" ); +} + +/* Explicitly define the macro so the preprocessor can see it in DHRL API */ +#define _CPU_Spin_wait _CPU_Spin_wait + #ifdef __cplusplus } #endif