caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Sylvain LE GALL <sylvain.le-gall@polytechnique.org>
To: Francois Rouaix <frouaix@yahoo.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] threads
Date: Wed, 20 Mar 2002 11:54:54 +0100	[thread overview]
Message-ID: <20020320105454.GA1297@gallu.polytechnique.fr> (raw)
In-Reply-To: <000001c1cfbb$460b3c60$ca01a8c0@homebox>

On Tue, Mar 19, 2002 at 06:59:38PM -0800, Francois Rouaix wrote:
> Is anyone using native threads in Ocaml 3.04 intensively on Linux these
> days ?
> 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.
> 

Hello,

I have tried this days to play with thread and mutex and condition.
Very funny but very messy. I do not use native thread but the problem is
that each thread is a process and when you exit because of a problem the
main thread if the child thread is detached, you can't make it ending. A
lot of problem also with signal handling ( a simple CtrL-C ). Each
thread catch it on is own... Not very simple. Of course i'm pretty sure
thread is very useful in certain situation but i think you can think
about using a non threaded process ( convert my program to this using
state for each object and a select on the different socket ... it has speed up the program ).

Thread have cause me also a lot of crash and non ending thread. I have
also a very non caml error : Segmentation Fault ( i do believe this can
not exist in Caml but now ... )

Sylvain LE GALL.

(of course if you intersted in getting your code in a non threaded
version i give you my solution... i know that all people in the list
will laugh at it because i am nearby a beginner :

type tcp_client_state = 
	TCP_Waiting 
	| TCP_Connected
	| TCP_Stopped


in my object 

	method run =
		match self#acq_state with
		TCP_Waiting -> self#waiting
		TCP_Connected -> self#connected

in the parent 

	method run =
	let (ready,_,_) = Unix.select self#list_socket [] [] delay_select
	in
	(* si les données dispo on réveille l'objet correspondant *)
	(* pour le serveur *)
		try
		while true do
			self#add_sortant
		done
		with Unix.Unix_error(Unix.EAGAIN,_,_) -> ()
-------------------
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-20 10:51 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 [this message]
2002-03-22 14:55 ` Xavier Leroy
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=20020320105454.GA1297@gallu.polytechnique.fr \
    --to=sylvain.le-gall@polytechnique.org \
    --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).