From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA26106; Thu, 20 Mar 2003 16:13:34 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA25538 for ; Thu, 20 Mar 2003 16:13:33 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2KFDWf20035; Thu, 20 Mar 2003 16:13:32 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA24645; Thu, 20 Mar 2003 16:13:32 +0100 (MET) Date: Thu, 20 Mar 2003 16:13:31 +0100 From: Xavier Leroy To: Alessandro Baretta Cc: Ocaml Subject: Re: [Caml-list] Question on Mutexes Message-ID: <20030320161331.B23584@pauillac.inria.fr> References: <3E772105.2000307@baretta.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <3E772105.2000307@baretta.com>; from alex@baretta.com on Tue, Mar 18, 2003 at 02:37:09PM +0100 X-Spam: no; 0.00; caml-list:01 mutexes:01 bug:01 threads:01 posix:01 unlocking:01 toplevel:01 necessarily:02 thread:02 locks:03 library:03 behavior:03 undefined:04 execute:04 exceptions:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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: > [...] > Is this a bug or a feature? Are threads supposed to be able > to unlock mutexes held by _other_ threads? No, but this isn't necessarily checked. The bytecode-level implementation of the thread library doesn't check, and will actually work correctly if thread A locks the mutex and thread B unlocks it. The system-level implementation of the thread library is a thin wrapper around POSIX or Win32 mutexes. The POSIX spec says that the behavior of unlocking by another thread than the one that locked is undefined: some implementations can signal an error, others can "do the right thing", others can crash. - Xavier Leroy ------------------- 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