[fpc-pascal] writeln: FPC runtime race conditions in external C threads

Alexander Grau alex at grauonline.de
Tue Jul 13 14:08:49 CEST 2010


Am 12.07.2010 um 22:58 schrieb Jonas Maebe:

> Alexander Grau wrote on Mon, 12 Jul 2010:
>
>> Am 12.07.2010 um 22:31 schrieb Jonas Maebe:
>>
>>> I forgot to mention: before this works, you have to create at  
>>> least one thread using the FPC RTL in order to initialise the  
>>> threading subsystem. It can be terminated/freed immediately, see  
>>> the test program that was committed together with the fix for an  
>>> example.
>>
>> That did the trick!  Seems to work -  I'm really curious how this  
>> works, since I assume there's probably no control over how the  
>> external C thread is created and so no chance to initialize  
>> something for the FPC runtime ...
>
> The FPC runtime support for such a thread is initialised the first  
> time you access a threadvar from that thread. And there's also a way  
> to make libpthread automatically call a "destructor" routine when  
> such a thread finishes (that's what I discovered today, and which  
> was the missing piece of the puzzle).
>
>
> Jonas

I think that's excellent -  how about the other (non-Unix) OS' s FPC  
supports, I assume they have the same problem with externally created  
threads? (e.g. has there already been found a similar solution for  
Win32 ?)





More information about the fpc-pascal mailing list