[fpc-devel] Threading support and C library under Linux/Unix

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Jun 24 10:03:09 CEST 2010


On 24 Jun 2010, at 09:27, Michael Schnell wrote:

[ARMv5 and lower atomic exchange]
> If there is no other way with this arch but an
> active spinning lock,

There is indeed none.

> the blocked thread should at least give up it's
> current time slice before retrying to get the lock, so that the  
> blocking
> thread can work and release the lock. otherwise (in a single CPU  
> system)
> the resting part of the time slice is deterministically wasted.

And on a multiple cpu system you can introduce extra latency if you  
give up your time slice early. The compromise is obviously to try for  
a few times and if it doesn't work after that, give up the time slice.  
However, at this time the interlocked* routines are completely OS- 
agnostic and that would require moving these routines to OS-specific  
include files (or add the ability for OS-specific include files of the  
system unit to override the implementation of these routines).

> AFAIK calling "sleep(0)" would give up the time slice.

It doesn't on all systems.


Jonas



More information about the fpc-devel mailing list