[fpc-devel] OO rewrite - technical questions
Daniël Mantione
daniel.mantione at freepascal.org
Mon Jul 19 17:16:02 CEST 2010
Op Mon, 19 Jul 2010, schreef Michael Schnell:
> On 07/19/2010 03:11 PM, Jonas Maebe wrote:
>> That's correct. FPC has largely platform-independent support for
>> threadvars, which is much more heavy-weight than simply using a segment
>> register (indirect procedure call depending on the thread manager, get
>> thread local storage pointer, index local storage with offset specific to
>> the threadvar).
> Nonetheless in the end a register is needed to be used that is preloaded with
> different values for different threads. Otherwise a thread can't know which
> one it is. Registers is the only per-Thread information that is granted to
> persist by the OS during preemption.
You could also work with the current thread id as a key to a pointer to
the threadvars. However, segment registers are indeed the way libpthread
resolves the TLS keys.
>> There have been attempts to get the segment register approach to work on
>> Windows, but afaik it always crashed on at least one Windows version.
> YAK
>
> I do know that gcc in Linux on X86 uses a segment register. I don't know how
> gcc works in Windows, but I suppose even Windows is assumed to restore all
> register values of a thread after a preemption.
Yes, though I am still puzzled how it works on x86_64; it seems regvars
there are also accessed using fs, but x86_64 prevents you from writing to
segment registers.
Daniël
More information about the fpc-devel
mailing list