[fpc-devel] TCustomApplication

Michael Schnell mschnell at lumino.de
Mon Aug 19 16:43:52 CEST 2013


On 08/19/2013 04:31 PM, Henry Vermaak wrote:
> How do you suppose that a mutex in linux will wake up an event loop?

The mutex gets taken before the loop is started. Now the loop blocks 
when taking it. It is freed whenever an event is scheduled.

Whether or not a mutex blocks when the same thread tries to take it that 
already owns it and whether a thread that does not "own" it can free it, 
is an implementation detail that here of course needs to be taken into 
account. (I once did a Mutex implementation that did block on re-take, 
but AFAIK there are different implementations.)

AFAIR the FUTEX system call (that is not a MUTEX itself, but only helps 
to implement one in user space) allows for doing this. But I don't know 
what in detail pthread.mutex does in detail.

(Anyway, I'll be doing a research on those details when I in fact should 
do an "Application" implementation that needs it.)

-Michael



More information about the fpc-devel mailing list