[fpc-devel] threadvar implementation

Hans-Peter Diettrich DrDiettrich1 at aol.com
Fri Aug 6 17:06:41 CEST 2010


Michael Van Canneyt schrieb:

> How can a C compiler be more efficient, if the threadvar concept does not
> exist in C ? On posix platforms, you must use a series of thread calls 
> to get to your 'thread-local' variable. When accessing a thread 
> variable, FPC uses the same series of calls as one would in C using 
> pthreads.

IMO there exists no requirement, that POSIX threadvars are accessible in 
Pascal. So FPC could use the Windows scheme for its own threadvars, 
where the OS only provides the address of an thread-specific memory 
block - equivalent to 1 POSIX "thread-local" variable. The referenced 
memory blocks, one per thread and containing all the Pascal threadvars, 
can be allocated on the heap.

DoDi




More information about the fpc-devel mailing list