caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chet Murthy <murthy.chet@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] recursive mutexes in ocaml
Date: Wed, 17 Jul 2013 00:28:28 -0700	[thread overview]
Message-ID: <5000924.vCd1HWCNpc@groupon> (raw)
In-Reply-To: <CAMu2m2+-+ZpYdbiA6D2Wo-hH0p_NZgSNGx7NE6KFetv7gL=dQw@mail.gmail.com>


Recently I'm writing some multi-threaded code, and ended up wishing I
had recursive mutexes.  Now .... I realize that this is a simple thing
to "get" -- just hack the code, maaaan.  But before (or, erm
.... whilst) I do that, I figured I'd ask -why- ocaml's mutexes aren't
recursive.  Or at least, why there isn't an option for recursive
mutexes?

I realize that at some level, you can -always- eschew recursive
mutexes by passing along extra parameters so that code can know
whether it's locked a particular mutex.  That said, it's (more than) a
bit of a pain, and surely complicates code ....

Is there some other -reason- that recursive mutexes aren't
implemented?  Or is it just a matter of taste?

Thanks,
--chet--

P.S. I found Markus' email about this:

>> I'd consider recursive lock acquisitions bad practice. There has
   never been a case in numerous complex bindings where I would have
   needed this feature. In mission-critical code I even prefer
   error-checking mutexes that prevent me from acquiring locks twice
   or releasing them once too often. As with everything multithreaded:
   the simpler the better. It's hard enough to reason about the simple
   case.

and this is about the ocaml master lock.  But it's the only instance I
find of somebody discussing recursive mutexes in ocaml.



  reply	other threads:[~2013-07-17  7:28 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       ` Chet Murthy [this message]
2013-07-17 10:54         ` [Caml-list] recursive mutexes in ocaml Gerd Stolpmann
2013-07-17 15:33           ` Edgar Friendly
2013-07-17 17:33         ` Xavier Leroy
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=5000924.vCd1HWCNpc@groupon \
    --to=murthy.chet@gmail.com \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).