[fpc-pascal] cpu_relax() in freepascal

Adriaan van Os fpc at microbizz.nl
Fri Nov 3 11:36:08 CET 2017


>     I want to implement the cpu_relax() function in order to use it
>     inside loops. However before, I would like to know if the fpc
>     compiler is doing an optimization of this kind.

I don't think one would you use that "inside a loop" or "to improve branching" but rather inside a 
wait-loop where constant polling, without regular pausing, keeps the processor unnecessarily busy. 
The operating system has calls for that purpose (e.g. usleep, see 
<https://linux.die.net/man/3/usleep>). That is not up to the compiler.

Regards,

Adriaan van Os




More information about the fpc-pascal mailing list