[Lazarus] semaphores

Michael Schnell mschnell at lumino.de
Tue Feb 14 13:27:56 CET 2012


On 02/14/2012 12:36 PM, Henry Vermaak wrote:
> No, you're wrong. 
I did a lot of research on pthread_mutex.. and I do know that it uses 
Futex when the underlying system provides same (not all Linux 
implementations on all architectures do have Futex). Thus unless you 
take additional care it can't be uses in an inter-process was.

I don't doubt that it is possible to use pthread_mutex.. for system wide 
semaphores, but as it uses user space memory you (at least) need to 
provide shared memory for the processes in question (and thus do 
something that is not the "standard" usage of the pthread-library. I 
never tried this. But I did try system 5 semaphores (also with FPC) some 
years ago and this did work nicely.

If Futex (via pthreadlib) really does work, it of course is faster than 
system5 semas, as in most cases a context switch can be avoided.

-Michael




More information about the Lazarus mailing list