Recursive mutex todo item

Havoc Pennington hp at
Thu Oct 26 16:03:12 PDT 2006


Looked into this some just now.

The trick is to emulate recursive mutexes, not use the glibc-specific 

It looks like glibc's PTHREAD_MUTEX_RECURSIVE won't work anyway because 
when you wait on a condition variable it only decrements the recursion 
count, but does not necessarily unlock all the way.

Java on the other hand will save the recursion count when you wait() on 
a recursive lock, and restore it when the wait() returns.

Since we use conditions for the lock we wanted to be recursive (the 
dispatch lock) we'll need the Java behavior.

I think I can code this pretty quickly and I also want to update the 
docs on how the condition variables have to work.

Hmm... if we're emulating recursive locks anyway, we may as well be able 
to emulate them in terms of the nonrecursive mutex funcs. I might code 
it that way. This means 1) we'll automatically always have recursive 
locks and 2) there will be no new platform-specific code so no danger of 
breaking BSD.


More information about the dbus mailing list