[fpc-pascal] cpu_relax() in freepascal

Matias Vara matiasevara at gmail.com
Fri Nov 3 12:02:21 CET 2017


Hi and thanks for the answers,

This feature seems to be a compiler intrinsic at least in the Intel C
> compiler. We don't have anything similar, so you have to fall back either
> to an asm procedure or a line of inline assembler. The compiler is also
> not doing an optimization similar to this. Free Pascal's inline assembler
> supports the PAUSE instruction though.
>
>
good to know that.


> But unless you plan to use this in a multithreaded spinloop because you're
> loading multiple cores of the CPU, it's better to let the operating system
> handle the wait. This instruction is certainly not the way to fix a "my
> app uses 100% CPU" scenario, just saying.
>
> Charlie


I am currently investigating the use of this instruction in my kernel. I
have wait-loops when accessing shared resources in a multicore system so
that could be a place to use it.
Also, I have situations in which the core just spends time in a loop so
this instruction may help to reduce energy consumption.  All this work is
however very experimental.


Matias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171103/63e2294b/attachment.html>


More information about the fpc-pascal mailing list