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: Basile STARYNKEVITCH <basile@s...>
Subject: [Caml-list] recursive mutexes?
Dear All,

Does the Mutex module allow "recursive" mutexes, so can I code
something like

let mylock = Mutex.create ();;

let innerf () =
   Mutex.lock mylock;
   Printf.printf "in innerf\n";
   Mutex.unlock mylock

let f () = 
    Mutex.lock mylock;
    (* do something complicated, then ... *)
    innerf ();
    Mutex.unlock mylock

I expect that the lock in innerf always succeed, since mylock is
already locked by the same thread in the caller function f. Am I right
in thinking so?  (the reference manual is not fully clear on this, and
it is an important point).

FWIW my plateform is Linux/x86 with pthreads but I would like a
"definitive" statement from our Inria team on this point.

AFAIK some Posix threads accept recursive locking.


email: basile<at>starynkevitch<dot>net 
alias: basile<at>tunes<dot>org 
8, rue de la Faïencerie, 92340 Bourg La Reine, France
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: