comp.lang.ada
 help / color / mirror / Atom feed
From: franke@minet.uni-jena.de (Frank Ecke)
Subject: Re: an error in Re: tasking
Date: 1998/10/07
Date: 1998-10-07T00:00:00+00:00	[thread overview]
Message-ID: <slrn71n73j.c0v.franke@pax01f.mipool.uni-jena.de> (raw)
In-Reply-To: 361B3260.7475@ipnsun5.in2p3.fr

On Wed, 07 Oct 1998 11:20:32 +0200, grave <grave@ipnsun5.in2p3.fr> wrote:

> I'm wanting to kill a task to let an exception propagate and kill the
> process.  How can I do this if the task is already excuting some part of
> code like this :
> 
> select
>    entry start;
>    Do_Some_Stuff_Here;
> or
>    terminate;
> end select;
> 
> Here I'm wanting to kill the task when it works in Do_Some_Stuff_Here;
> 
> Is this possible ?


You select should read

   select
      accept Start;
      Do_Some_Stuff_Here;
   or
      terminate;
   end select;

for it is not possible to declare an entry within a branch of a select
statement.

   To kill (or abort) a task, use ``abort Task_Name {, Task_Name};'' (see
ARM 9.8).  In order to abort the task from within Do_Some_Stuff_Here (i.e., to
let that task kill itself), you may issue

   Self : Ada.Task_Identification.Task_ID :=
     Ada.Task_Identification.Current_Task;

   ...

   Ada.Task_Identification.Abort_Task(Self);

   Note that trying to kill the task (from outside) ``when it works in
Do_Some_Stuff_Here'' gives raise to a race condition since you cannot be sure
that the task to be killed is already (or still) inside Do_Some_Stuff_Here when
you issue the abort.

   Note further that if Do_Some_Stuff_Here were part of the accept statement
corresponding to the Start entry, it would be executed as part of an abort-
deferred operation, namely the rendezvous between the caller and the callee,
and could thus not be aborted.

> I'm wanting to kill a task to let an exception propagate and kill the
> process.

I am a bit puzzled by this statement.  Could you please give further
explanations?


Frank

--
Frank Ecke <franke@minet.uni-jena.de>


       In a world without walls and fences, who needs windows and gates?




  reply	other threads:[~1998-10-07  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-07  0:00 tasking grave
1998-10-07  0:00 ` an error in tasking grave
1998-10-07  0:00   ` Frank Ecke [this message]
1998-10-08  0:00     ` Frank Ecke
1998-10-16  0:00       ` Robert A Duff
1998-10-16  0:00       ` Tucker Taft
1998-10-19  0:00         ` Frank Ecke
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox