From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3089024a3e433566 X-Google-Attributes: gid103376,public From: franke@minet.uni-jena.de (Frank Ecke) Subject: Re: an error in Re: tasking Date: 1998/10/07 Message-ID: #1/1 X-Deja-AN: 398689327 References: <361B31AA.6714@ipnsun5.in2p3.fr> <361B3260.7475@ipnsun5.in2p3.fr> Organization: Department of Computer Science, FSU Jena, Germany Reply-To: franke@minet.uni-jena.de Newsgroups: comp.lang.ada Date: 1998-10-07T00:00:00+00:00 List-Id: On Wed, 07 Oct 1998 11:20:32 +0200, grave 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 In a world without walls and fences, who needs windows and gates?