Home > database >  Why does hint::spin_loop use ISB on aarch64?
Why does hint::spin_loop use ISB on aarch64?

Time:01-22

In std::hint there's a spin_loop function with the following definition in its documentation:

Emits a machine instruction to signal the processor that it is running in a busy-wait spin-loop (“spin lock”).

Upon receiving the spin-loop signal the processor can optimize its behavior by, for example, saving power or switching hyper-threads.

Depending on the target architecture, this compiles to either:

That last one has got my head spinning a little bit (

  •  Tags:  
  • Related