Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] recursive mutexes?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] recursive mutexes?
> Does the Mutex module allow "recursive" mutexes

No.  A thread blocks forever if it attempts to lock a mutex it already
locked before.

> (the reference manual is not fully clear on this, and
> it is an important point).

I agree the documentation should be clearer on this point.

> AFAIK some Posix threads accept recursive locking.

Some do, but the POSIX 1003.1c standard specifies non-recursive
mutexes only.  There are endless arguments on the usefulness/evilness
of recursive mutexes on comp.programming.threads; the jury is still
out on this one.  

Of course, it is not difficult to implement recursive mutexes yourself
on top of normal mutexes.  You won't be able to use your recursive
mutexes in conjunction with condition variables, though.

- Xavier Leroy
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: