caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] sources for ZINC?
@ 2013-07-12 19:59 Nicolas Ojeda Bar
  2013-07-16  2:39 ` [Caml-list] " Hongbo Zhang
  2013-07-16 15:33 ` [Caml-list] " Xavier Leroy
  0 siblings, 2 replies; 10+ messages in thread
From: Nicolas Ojeda Bar @ 2013-07-12 19:59 UTC (permalink / raw)
  To: caml-list

Dear list,

I was wondering if the sources for ZINC, described in X. Leroy's thesis
are available anywhere...?

Thanks!
Nicolas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Caml-list] Re: sources for ZINC?
  2013-07-12 19:59 [Caml-list] sources for ZINC? Nicolas Ojeda Bar
@ 2013-07-16  2:39 ` Hongbo Zhang
  2013-07-16 15:33 ` [Caml-list] " Xavier Leroy
  1 sibling, 0 replies; 10+ messages in thread
From: Hongbo Zhang @ 2013-07-16  2:39 UTC (permalink / raw)
  To: Nicolas Ojeda Bar, Caml List

On 7/12/13 3:59 PM, Nicolas Ojeda Bar wrote:
> Dear list,
>
> I was wondering if the sources for ZINC, described in X. Leroy's thesis
> are available anywhere...?
>
> Thanks!
> Nicolas
>
Hi Nicolas,
    basically current the compiler source tree (excluding asmrun and 
typechecking)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] sources for ZINC?
  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 ` Xavier Leroy
  2013-07-16 17:06   ` Benedikt Meurer
  1 sibling, 1 reply; 10+ messages in thread
From: Xavier Leroy @ 2013-07-16 15:33 UTC (permalink / raw)
  To: Nicolas Ojeda Bar; +Cc: caml-list

On 2013-07-12 21:59, Nicolas Ojeda Bar wrote:
> Dear list,
> 
> I was wondering if the sources for ZINC, described in X. Leroy's thesis
> are available anywhere...?

Caml Light is pretty close to what's described in the ZINC report,
esp. the abstract machine.  Available here:

http://caml.inria.fr/caml-light/release.html

- Xavier Leroy

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] sources for ZINC?
  2013-07-16 15:33 ` [Caml-list] " Xavier Leroy
@ 2013-07-16 17:06   ` Benedikt Meurer
  2013-07-16 19:54     ` Ashish Agarwal
  0 siblings, 1 reply; 10+ messages in thread
From: Benedikt Meurer @ 2013-07-16 17:06 UTC (permalink / raw)
  To: Nicolas Ojeda Bar; +Cc: caml-list


On Jul 16, 2013, at 17:33 , Xavier Leroy <Xavier.Leroy@inria.fr> wrote:

> On 2013-07-12 21:59, Nicolas Ojeda Bar wrote:
>> Dear list,
>> 
>> I was wondering if the sources for ZINC, described in X. Leroy's thesis
>> are available anywhere...?
> 
> Caml Light is pretty close to what's described in the ZINC report,
> esp. the abstract machine.  Available here:
> 
> http://caml.inria.fr/caml-light/release.html

http://caml.inria.fr/caml-light/release.en.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] sources for ZINC?
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Ashish Agarwal @ 2013-07-16 19:54 UTC (permalink / raw)
  To: Benedikt Meurer; +Cc: Nicolas Ojeda Bar, caml-list

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

>
> > http://caml.inria.fr/caml-light/release.html
>
> http://caml.inria.fr/caml-light/release.en.html


http://ocaml.org/caml-light/releases/   :)

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Caml-list] recursive mutexes in ocaml
  2013-07-16 19:54     ` Ashish Agarwal
@ 2013-07-17  7:28       ` Chet Murthy
  2013-07-17 10:54         ` Gerd Stolpmann
  2013-07-17 17:33         ` Xavier Leroy
  0 siblings, 2 replies; 10+ messages in thread
From: Chet Murthy @ 2013-07-17  7:28 UTC (permalink / raw)
  To: caml-list


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.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] recursive mutexes in ocaml
  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
  1 sibling, 1 reply; 10+ messages in thread
From: Gerd Stolpmann @ 2013-07-17 10:54 UTC (permalink / raw)
  To: Chet Murthy; +Cc: caml-list

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
------------------------------------------------------------



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] recursive mutexes in ocaml
  2013-07-17 10:54         ` Gerd Stolpmann
@ 2013-07-17 15:33           ` Edgar Friendly
  0 siblings, 0 replies; 10+ messages in thread
From: Edgar Friendly @ 2013-07-17 15:33 UTC (permalink / raw)
  To: Gerd Stolpmann; +Cc: Chet Murthy, caml-list

[-- 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 --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] recursive mutexes in ocaml
  2013-07-17  7:28       ` [Caml-list] recursive mutexes in ocaml Chet Murthy
  2013-07-17 10:54         ` Gerd Stolpmann
@ 2013-07-17 17:33         ` Xavier Leroy
  2013-07-17 17:50           ` Chet Murthy
  1 sibling, 1 reply; 10+ messages in thread
From: Xavier Leroy @ 2013-07-17 17:33 UTC (permalink / raw)
  To: Chet Murthy; +Cc: caml-list

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] recursive mutexes in ocaml
  2013-07-17 17:33         ` Xavier Leroy
@ 2013-07-17 17:50           ` Chet Murthy
  0 siblings, 0 replies; 10+ messages in thread
From: Chet Murthy @ 2013-07-17 17:50 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: caml-list


Xavier,

Wow, that's excellent.  Made my morning!  I've implemented Java's
monitors, so yeah, they're as you describe, and I cannot imagine doing
it any other way.  What were they -thinkin'- in the POSIX committee?

Ah, well.

OK.  I'll just add the (few) lines of code needed to get basic
recursive mutexes for locking purposes, and leave it at that.  Given
Butenhof's analysis, I -fully- agree with leavin' 'em out of ocaml.
Yikes!

--chet--

On Wednesday, July 17, 2013 07:33:41 PM Xavier Leroy wrote:
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-07-17 17:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2013-07-17 17:50           ` Chet Murthy

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).