[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Are mutexes "recursive"?

This page is part of the web mail archives of SRFI 18 from before July 7th, 2015. The new archives for SRFI 18 contain all messages, not just those from before July 7th, 2015.

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