caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Alessandro Baretta <alex@baretta.com>
Cc: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Question on Mutexes
Date: Thu, 20 Mar 2003 16:13:31 +0100	[thread overview]
Message-ID: <20030320161331.B23584@pauillac.inria.fr> (raw)
In-Reply-To: <3E772105.2000307@baretta.com>; from alex@baretta.com on Tue, Mar 18, 2003 at 02:37:09PM +0100

> 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


  parent reply	other threads:[~2003-03-20 15:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-18 13:37 Alessandro Baretta
2003-03-18 18:43 ` David Brown
2003-03-20 15:13 ` Xavier Leroy [this message]
2003-03-24 11:19   ` Alessandro Baretta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030320161331.B23584@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=alex@baretta.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).