Cliff Woolley wrote:
On Thu, 21 Jul 2005, Nick Kew wrote:
On Wed, 20 Jul 2005, Henry Jen wrote:
I need to have recursive(NESTED) mutex support in our project.
Currently apr is relying on pthread lib to provide
pthread_mutexattr_settype to provide recursive support, unfortunately,
that does not seem to be in POSIX standard and is not available on the
requested linux platform(see
http://www.lynuxworks.com/products/posix/function-calls.php3).
I plan to implement that in apr by extend current apr_thread_mutex_t to
include a pthread_t and an integer for count, and modify the lock/unlock
accordingly. So here are couple questions:
1. Is this a reasonable solution or I overlook something? Or maybe
someone had done similar?
Looks reasonable to me at first glance. Bear in mind that anything
APR exports should be cross-platform, so you'll want to implement it
in the platform-independent layer. Unless I'm misunderstanding the
scope of what you propose.
2. How fast can this modification can be rolled into a formal apr
release? It is going to be API compatible but not ABI(as the structure
changed, only in the case of underlying pthread lib does not support
recursive mutex, so should be OK)
That's likely to be a while: it'll need to get reviewed, agreed on,
and then used in a test version for a while, then await sufficient
general agreement for a release incorporating it.
I have this vague recollection that we specifically excluded recursive
mutexes from the API at some point in the past because there were deadlock
problems that made it impossible to implement this portably. Perhaps
Justin or Aaron remembers more details?
I just looked into SVN at 0.9.4(thanks Joe for pointing me there),
that's pretty much what I planned to do. The trylock does not seem to be
right though.
However, I would like to know what's wrong with that implementation and
try to figure out how it can be fixed.
Cheers,
Henry