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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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 Received: by 10.68.74.201 with SMTP id w9mr1879115pbv.0.1327597312572; Thu, 26 Jan 2012 09:01:52 -0800 (PST) Path: lh20ni226739pbb.0!nntp.google.com!news1.google.com!postnews.google.com!w4g2000vbc.googlegroups.com!not-for-mail From: Anh Vo Newsgroups: comp.lang.ada Subject: Re: task abortion Date: Thu, 26 Jan 2012 08:47:16 -0800 (PST) Organization: http://groups.google.com Message-ID: <108b8a34-9dea-4d10-9560-239f5ac62a5f@w4g2000vbc.googlegroups.com> References: <393dafce-883a-4b6c-82a6-1657de15d2f3@h12g2000yqg.googlegroups.com> <19pfl6kbf35z6.1ao0njyuiqbls.dlg@40tude.net> <94aa02cf-ccd3-4a08-999a-2bbe562f5bef@q8g2000yqa.googlegroups.com> NNTP-Posting-Host: 149.32.224.35 Mime-Version: 1.0 X-Trace: posting.google.com 1327597312 7116 127.0.0.1 (26 Jan 2012 17:01:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 26 Jan 2012 17:01:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w4g2000vbc.googlegroups.com; posting-host=149.32.224.35; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-01-26T08:47:16-08:00 List-Id: On Jan 26, 1:12=A0am, tonyg wrote: > On Jan 25, 10:43=A0am, "Dmitry A. Kazakov" > wrote: > > > > > > > > > > > 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 o= f > > > 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 free= d > > when the task is aborted. But if you have some globally allocated memor= y, > > semaphores etc, they all get lost unless freed by some local controlled > > objects, "holders" releasing the resources upon finalization, as they l= eave > > the scope upon task abort. Now: > > > 2.b. What if the task is frozen in an abort-deferred thing? Finalizatio= n 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 t= asks > > impose no problems anyway. Ergo, it is not likely you would need to abo= rt > > any task. > > > If you decided for aborting, you would have to redesign almost everythi= ng > > and in an extremely careful way in order to make tasks logically aborta= ble. > > 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. Kazakovhttp://www.dmitry-kazakov.de > > Since I wrote my message I have discovered the package > Ada.Task_Identification. I totally agree with your argument on not > having them fail in the first place. My strategy should be then not to > abort :), I'm going to use that package just to monitor my tasks and > see if any freeze for some IO reason. Thanks for the advice. Just in case your task disappear which I do not expect it will, you can use package Ada.Task_Termination to query the reason (Normal, Abnormal, Unhandled_Exception) it dies. Anh Vo