caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Edgar Friendly <thelema314@gmail.com>
To: Gerd Stolpmann <info@gerd-stolpmann.de>
Cc: Chet Murthy <murthy.chet@gmail.com>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] recursive mutexes in ocaml
Date: Wed, 17 Jul 2013 11:33:02 -0400	[thread overview]
Message-ID: <CAL-jcAkrZ9NHKBp5LkH6P9GLXqpS+D8DSYd4cyPZAL0+LHvt+w@mail.gmail.com> (raw)
In-Reply-To: <1374058447.21437.37.camel@zotac>

[-- Attachment #1: Type: text/plain, Size: 3042 bytes --]

There was some back and forth on the batteries-devel mailing list about
getting rid of BatRMutex, batteries' implementation of recursive
mutexes(search the archives).  They're still in, if you want to use them.

E.


On Wed, Jul 17, 2013 at 6:54 AM, Gerd Stolpmann <info@gerd-stolpmann.de>wrote:

> Am Mittwoch, den 17.07.2013, 00:28 -0700 schrieb Chet Murthy:
> > 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?
>
> The multi-threading feature in ocaml is quite old. I guess there was
> some motivation to keep it as simple as possible, e.g. for maximizing
> portability, so you can also build ocaml on an OS that does not support
> such fancy features. Nowadays the OS landscape is quite different, of
> course, and such frugality can be seen as limitation.
>
> The demand for recursive mutexes is certainly low, because you can
> easily have your own little wrapper around Mutex to get them (there is
> normally an easy way to recognize the owner). It's just a counter after
> all. But yes, having this directly in Mutex would make it simpler. Maybe
> file a wish in the bugtracker?
>
> Gerd
>
>
> >
> > 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.
> >
> >
> >
>
> --
> ------------------------------------------------------------
> Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany
> gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
> Phone: +49-6151-153855                  Fax: +49-6151-997714
> ------------------------------------------------------------
>
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 4199 bytes --]

  reply	other threads:[~2013-07-17 15: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 [this message]
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=CAL-jcAkrZ9NHKBp5LkH6P9GLXqpS+D8DSYd4cyPZAL0+LHvt+w@mail.gmail.com \
    --to=thelema314@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=info@gerd-stolpmann.de \
    --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;
as well as URLs for NNTP newsgroup(s).