English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Question on Mutexes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-03-18 (13:32)
From: Alessandro Baretta <alex@b...>
Subject: [Caml-list] Question on Mutexes
If thread t1 locks mutex m, can thread t2 unlock it?

I ask because I get no sign of exceptions being thrown when 
I execute the following code in the toplevel:

let m = Mutex.create ()
let () = Mutex.lock m
let f m' = Mutex.unlock m'
let t = Thread.create f m
let () = Mutex.lock m

Also, the final call to Mutex.lock does not block the 
execution of the program by any significant time, which 
means that mutex m is unlocked by thread t before being 
locked once again by the original thread.

Is this a bug or a feature? Are threads supposed to be able 
to unlock mutexes held by _other_ threads?


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