On Mon, 4 Mar 2013, Michael Schnell wrote:
On 03/04/2013 09:49 AM, Michael Van Canneyt wrote:
The solution must work on ALL platforms...
Of course.
I don't remember ever having seen a system (Windows, Linux, x86, ARM, NIOS
(similar top MIPS) ) where the C compiler does a library call when accessing
a threadvar. Usually a register is dedicated for this purpose that is loaded
with a thread specific value by the OS. I do know C compiler implementations
that don't support threadvars at all and thus are unable to support FUTEX and
with that low level thread synchronization is a lot slower as always a
userland/system switch is necessary. Here hardware (atomic instructions) and
the OS implementation (e.g. "Atomic Region" to overcome such limitations for
userland) comes into play.
I remember from a discussion some years ago that fpc uses a (supposedly
arch/platform depending) library call with any access to to a threadvar
instead of using the appropriate (arch/platform depending) register. But I
did not recheck recently.
We use pthreads on non-windows, and GetTLS/SetTLS on Windows.
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel