Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] threads
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-03-20 (10:51)
From: Sylvain LE GALL <sylvain.le-gall@p...>
Subject: Re: [Caml-list] threads
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.


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_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,_,_) = self#list_socket [] [] delay_select
	(* si les données dispo on réveille l'objet correspondant *)
	(* pour le serveur *)
		while true do
		with Unix.Unix_error(Unix.EAGAIN,_,_) -> ()
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: