Version française
Home     About     Download     Resources     Contact us    
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.

regards.
-- 

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners