caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* The best way to circumvent the lack of Thread.kill ?
@ 2005-11-02  9:52 Julien Narboux
  2005-11-02 10:54 ` [Caml-list] " Richard Jones
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Julien Narboux @ 2005-11-02  9:52 UTC (permalink / raw)
  To: caml-list

Hi,

I just encountered the Thread.kill "not implemented" exception.

A google search gives me this answer from Xavier Leroy on the caml 
weekly news (http://sardes.inrialpes.fr/~aschmitt/cwn/2003.05.20.html) :

"The general solution is to avoid using Thread.kill.  Terminating another
thread at arbitrary times is an inherently unsafe operation: the
killed thread may be holding mutexes, for instance.  There's a good
explanation of the problems in the Java documentation:
http://java.sun.com/j2se/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html
explaining why they "deprecated" their equivalent of Thread.kill."

Here is the relevant part of this web page :

"Most uses of stop should be replaced by code that simply modifies some 
variable to indicate that the target thread should stop running. The 
target thread should check this variable regularly, and return from its 
run method in an orderly fashion if the variable indicates that it is to 
stop running. (This is the approach that JavaSoft's Tutorial has always 
recommended.) To ensure prompt communication of the stop-request, the 
variable must be volatile (or access to the variable must be synchronized)."

My problem is that I don't want to pollute my target thread with checks 
for a variable.

Indeed, I am writing a graphical user interface for an automated theorem 
prover.
I have a function f which decides if a theorem is true or not. It can 
terminate quickly or take ages, and I want to have an "interrupt" button 
in the graphical user interface so the user can stop the computation if 
he wants to. I do not want to have GUI related code in the automated 
theorem proving part of the program, it would not be clean imho.

What is the best solution ? start a new process and use the kill at the 
operating system level ?
(to make things even worse I need something which works on linux, 
windows and macosx)

Kindest regards.

Julien Narboux






^ permalink raw reply	[flat|nested] 20+ messages in thread
* RE: [Caml-list] The best way to circumvent the lack of Thread.kill ?
@ 2005-11-02 11:33 EL CHAAR Rabih   SGAM/AI/SAM
  2005-11-08  3:23 ` Igor Pechtchanski
  0 siblings, 1 reply; 20+ messages in thread
From: EL CHAAR Rabih   SGAM/AI/SAM @ 2005-11-02 11:33 UTC (permalink / raw)
  To: Julien Narboux, Richard Jones; +Cc: caml-list

If i'm not mistaken, fork is not also implemented under windows.

Rabih

-----Message d'origine-----
De : caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr]De la part de Julien Narboux
Envoyé : mercredi 2 novembre 2005 12:22
À : Richard Jones
Cc : caml-list@yquem.inria.fr
Objet : Re: [Caml-list] The best way to circumvent the lack of
Thread.kill ?


Richard Jones wrote:

>On Wed, Nov 02, 2005 at 10:52:12AM +0100, Julien Narboux wrote:
>  
>
>>My problem is that I don't want to pollute my target thread with checks 
>>for a variable.
>>
>>Indeed, I am writing a graphical user interface for an automated theorem 
>>prover.
>>    
>>
>
>How about forking off the theorem prover as a separate process?  You
>can communicate the result back to the main program using either a
>status code or a pipe (depending on how complex the result structure
>is).  The interrupt button just kills the forked process.
>
>Rich.
>
>  
>
Yes, but the problem is that under the native windows port (see 
http://caml.inria.fr/pub/docs/manual-ocaml/manual035.html) :

"kill, pause not implemented (no inter-process signals in Windows)"


Julien Narboux

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
*************************************************************************
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite. 
Tout message electronique est susceptible d'alteration. 
SG Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.

Decouvrez l'offre et les services de SG Asset Management sur le site www.sgam.fr 

                                ********

This message and any attachments (the "message") are confidential and intended solely for the addressees.
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration. 
Neither SG Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. 

*************************************************************************


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2005-11-09 13:30 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-02  9:52 The best way to circumvent the lack of Thread.kill ? Julien Narboux
2005-11-02 10:54 ` [Caml-list] " Richard Jones
2005-11-02 11:22   ` Julien Narboux
2005-11-02 13:00     ` Jacques Garrigue
2005-11-02 12:57       ` Julien Narboux
2005-11-02 13:23 ` Gerd Stolpmann
2005-11-02 14:00   ` Gerd Stolpmann
2005-11-02 14:32   ` Julien Narboux
2005-11-02 15:07     ` Gerd Stolpmann
2005-11-02 14:53 ` David Teller
2005-11-02 16:24   ` Alessandro Baretta
2005-11-02 17:00     ` David Teller
2005-11-02 18:43       ` Alessandro Baretta
2005-11-02 18:29         ` David Teller
2005-11-08 20:36           ` Jonathan Bryant
2005-11-09  1:18             ` Grégory Guyomarc'h
2005-11-09 12:37             ` Richard Jones
     [not found]             ` <4371A0A6.4010306@laposte.net>
2005-11-09 13:32               ` Jonathan Bryant
2005-11-02 11:33 EL CHAAR Rabih   SGAM/AI/SAM
2005-11-08  3:23 ` Igor Pechtchanski

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).