Email list hosting service & mailing list manager


Are mutexes "recursive"? Jim Blandy 23 Mar 2000 21:51 UTC

The mutexes of many thread systems (like Java) are "recursive",
meaning that:
1) if a thread T holds a mutex M, then if T tries to lock M again,
   the operation succeeds without blocking, and
2) M remains locked until T has unlocked M as many times as it locked it.

(I'm not sure that's a correct description of the behavior I have in
mind, but it's a very common feature, and I'm sure you're familiar
with it.)

I can't tell from reading the SRFI whether its mutexes are recursive
or not.  It's certainly possible to build recursive mutexes using
non-recursive mutexes.  However, I think you'll often need to rely on
someone else's mutexes being recursive (i.e., mutexes which protect
some structure provide by a library, and which aren't under your
control), so it would be nicer if this were a property people could
assume.