caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Francois Rouaix <frouaix@yahoo.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] threads
Date: Fri, 22 Mar 2002 15:55:35 +0100	[thread overview]
Message-ID: <20020322155535.A6948@pauillac.inria.fr> (raw)
In-Reply-To: <000001c1cfbb$460b3c60$ca01a8c0@homebox>; from frouaix@yahoo.com on Tue, Mar 19, 2002 at 06:59:38PM -0800

> Is anyone using native threads in Ocaml 3.04 intensively on Linux these
> days ?

We occasionally get bug reports similar to yours, under Linux.  It's
hard to say whether it's a bug in the OCaml system thread library, or
in LinuxThreads itself.

> The program "hangs", ps looks like this. Looks like a thread is stuck.
> 
> 18964 pts/3    S      0:00 ./camella.opt
> 18965 pts/3    Z      0:00 [camella.opt <defunct>]
> 18967 pts/3    S      0:00 ./camella.opt

Actually, it looks like the thread manager thread (PID N+1, where N is
the initial PID of the program) died.  It should not, and it is not
surprising that the program hangs, since once the thread manager is
gone the program can no longer create new threads.

> I'm playing with a Gnutella servent, and I'm experimenting crashes
> (bytecode and native).
> I'm using the unix library heavily. So far, I'm aware that the DNS calls
> are not reentrant, but the rest of the library calls should be okay.

Yes, that's another issue: OCaml allows several threads to call
Unix.gethostbyname concurrently (without holding the master mutex),
yet most if not all implementations of gethostbyname() are not
reentrant.

As Nikolaj Bjorner mentioned, some systems provide a reentrant
gethostbyname_r() function, not necessarily with the same interface,
though, making it very hard to use in the Unix library.

(An easy way to see if your problems are related to gethostbyname is
to protect calls to Unix.gethostbyname by a mutex, to ensure that only
one at a time is performed.)

- 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:[~2002-03-22 14:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-20  2:59 Francois Rouaix
2002-03-20  8:11 ` Remi VANICAT
2002-03-20 10:54 ` Sylvain LE GALL
2002-03-22 14:55 ` Xavier Leroy [this message]
2005-06-10 17:56 Threads Jonathan Bryant
2005-06-11  7:46 ` [Caml-list] Threads Christophe Raffalli
2005-06-11 14:02   ` james woodyatt
2005-06-11 21:03     ` Christophe Raffalli
2009-09-08 17:33 threads ygrek
2009-09-08 23:20 ` [Caml-list] threads Philippe Wang
2009-09-10 18:17   ` ygrek

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=20020322155535.A6948@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=frouaix@yahoo.com \
    /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).