From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA06855 for caml-redistribution@pauillac.inria.fr; Fri, 18 Feb 2000 00:29:49 +0100 (MET) Resent-Message-Id: <200002172329.AAA06855@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA17556 for ; Wed, 16 Feb 2000 12:31:44 +0100 (MET) Received: from julie.univ-savoie.fr (univax.univ-savoie.fr [193.48.120.32]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id MAA28689; Wed, 16 Feb 2000 12:31:28 +0100 (MET) Received: from univ-savoie.fr (lama-d134.univ-savoie.fr [193.48.123.134]) by julie.univ-savoie.fr (8.9.3/jtpda-5.3.3) with ESMTP id MAA94348 ; Wed, 16 Feb 2000 12:31:22 +0100 (CET) Sender: raffalli@univ-savoie.fr Message-ID: <38AA8A8B.17558090@univ-savoie.fr> Date: Wed, 16 Feb 2000 12:31:23 +0100 From: Christophe Raffalli Organization: Laboratoire de =?iso-8859-1?Q?Math=E9matiques?=, =?iso-8859-1?Q?Universit=E9?= de Savoie X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.13-7mdk i686) X-Accept-Language: fr, en MIME-Version: 1.0 To: Xavier Leroy CC: caml-list@inria.fr Subject: Re: Thread feature missing References: <20000211111749.34427@pauillac.inria.fr> <20000213073403Q.garrigue@kurims.kyoto-u.ac.jp> <38A7B721.172F585C@univ-savoie.fr> <20000215170653.54672@pauillac.inria.fr> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Resent-From: weis@pauillac.inria.fr Resent-Date: Fri, 18 Feb 2000 00:29:49 +0100 Resent-To: caml-redistribution@pauillac.inria.fr Xavier Leroy wrote: > > - No way to wait for one thread to finish among many (equivalent of > > join, but taking a list of threads as argument) > > This isn't supported directly in POSIX threads. However, you can > easily program it yourself using e.g. events: allocate a channel, have > each thread send a message on it when it terminates, and wait for a > message on the channel. The good thing about this method is that you > can put whatever you need in the message (thread ID, return value, etc). > Ok, but if I wait for thread A or B and thread C stops, then I will wake up and test on the channel if it is thread A or B. This means waiting in a loop. If there are a lot of small threads with short life ... this is not very good. I think it is better to have one channel for each thread and wait using Event.select that thread A or B send on their respective channel. Am I right ? I have another little pb which is that Many threads may be waiting for A to terminate. So I could do a loop always sending on the termination channel of A. But is there a better way ? A kind of broadcast forever a value on a channel ? Yet another question: What is the size of a thread in both cases: bytecode and native. Is 1000 threads reasonable ? > > - No way to send a signal to a thread (it would be useful to make a > > thread raise an exception from another thread). > > I agree this would be nice, and can easily be implemented in the case > of bytecode threads. For POSIX threads, one could try using > cancellation to handle this, but I'm not sure it can be done in a > portable way. For Win32 threads, I don't know how to do it. > I think it is worth a try ! even if the semantic means that after handling the exception, the thread must terminates and it will never receive another exception of this kind. What I mean is that a clean interface to pthread_cleanup_push would be enough And probably portable (I do not know for Win32 ?) > > A Last question: How to make the GC collects an inacessible thread ? The pb is that the definition of inacessible is hard for a thread: it means no pointer to the thread (thats easy), but also no more common mutable variables or channel : the thread can not interact with the outside world. Moreover, one must also define the outside world by choosing a main thread ... All this looks hard, but it is necessary for my application ! In a first approximation I will have a lot of potentialy dead thread running :-( -- Christophe Raffalli Université de Savoie Batiment Le Chablais, bureau 21 73376 Le Bourget-du-Lac Cedex tél: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI