From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Chet Murthy <murthy.chet@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] recursive mutexes in ocaml
Date: Wed, 17 Jul 2013 19:33:41 +0200 [thread overview]
Message-ID: <51E6D575.9010406@inria.fr> (raw)
In-Reply-To: <5000924.vCd1HWCNpc@groupon>
Hi Chet,
> I figured I'd ask -why- ocaml's mutexes aren't recursive. Or at
> least, why there isn't an option for recursive mutexes?
Dave Butenhof, one of the main authors of POSIX threads, makes rather
strong points against recursive mutexes:
http://tinyurl.com/butenhof-recursive-mutexes
The killer issue in my opinion is how to make recursive mutexes play
well with pthread_cond_wait() / Condition.wait: POSIX's
pthread_cond_wait() only releases the mutex once, which leads to all
sorts of deadlock if it's been acquired N>1 times. I believe Java
has a more useful behavior, whereas the mutex is released N times,
then reacquired N times. But this cannot be implemented easily on top
of POSIX threads. And don't get me started on Win32 threads...
It might make sense to have recursive mutexes as a separate type,
different from ordinary mutexes, so that it's not usable in
conjunction with Condition.wait. Apparently, Batteries has/had that.
- Xavier Leroy
next prev parent reply other threads:[~2013-07-17 17:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-12 19:59 [Caml-list] sources for ZINC? Nicolas Ojeda Bar
2013-07-16 2:39 ` [Caml-list] " Hongbo Zhang
2013-07-16 15:33 ` [Caml-list] " Xavier Leroy
2013-07-16 17:06 ` Benedikt Meurer
2013-07-16 19:54 ` Ashish Agarwal
2013-07-17 7:28 ` [Caml-list] recursive mutexes in ocaml Chet Murthy
2013-07-17 10:54 ` Gerd Stolpmann
2013-07-17 15:33 ` Edgar Friendly
2013-07-17 17:33 ` Xavier Leroy [this message]
2013-07-17 17:50 ` Chet Murthy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51E6D575.9010406@inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=murthy.chet@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox