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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,345e13136367c50f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.189.72 with SMTP id gg8mr10146850pbc.4.1327488224498; Wed, 25 Jan 2012 02:43:44 -0800 (PST) Path: lh20ni222046pbb.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: task abortion Date: Wed, 25 Jan 2012 11:43:14 +0100 Organization: cbb software GmbH Message-ID: <19pfl6kbf35z6.1ao0njyuiqbls.dlg@40tude.net> References: <393dafce-883a-4b6c-82a6-1657de15d2f3@h12g2000yqg.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-01-25T11:43:14+01:00 List-Id: On Wed, 25 Jan 2012 02:11:55 -0800 (PST), tonyg wrote: > I want to be able to abort a task if it has not responded for a while, > and then start a new one in its stead. > > I have a pointer going to the concerned task. > > Each task has a 'stop accept' in its rendezvous which forces it out of > its loop so that it ends, but if the task has frozen for some reason > then I want to abort. What are you going to achieve by that? Consider the scenarios: 1. The task crashed, it is already terminated then. 2. The task is looping somewhere: 2.a. What about the resources it owns? Local resources are usually freed when the task is aborted. But if you have some globally allocated memory, semaphores etc, they all get lost unless freed by some local controlled objects, "holders" releasing the resources upon finalization, as they leave the scope upon task abort. Now: 2.b. What if the task is frozen in an abort-deferred thing? Finalization is such a thing. Abort-deferred stuff cannot be aborted. Note that system I/O is most likely non-abortable. I.e. you would not be able to abort Ada.Text_IO.Get_Line or recv on a socket etc anyway. All in one, aborting tasks doing complex stuff is not likely to work in a reasonable way. Aborting tasks doing simple stuff is not needed, such tasks impose no problems anyway. Ergo, it is not likely you would need to abort any task. If you decided for aborting, you would have to redesign almost everything and in an extremely careful way in order to make tasks logically abortable. That means to make continuation possible and meaningful after aborting some tasks. Now a guess: making the tasks right and thus preventing a need aborting them, would probably be far less efforts... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de