caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: caml_list@inria.fr
Subject: [Caml-list] recursive mutexes?
Date: Fri, 8 Nov 2002 16:20:57 +0100	[thread overview]
Message-ID: <15819.54873.817342.980555@hector.lesours> (raw)

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


             reply	other threads:[~2002-11-08 15:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-08 15:20 Basile STARYNKEVITCH [this message]
2002-11-11  9:55 ` Xavier Leroy

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=15819.54873.817342.980555@hector.lesours \
    --to=basile@starynkevitch.net \
    --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).