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.222.71 with SMTP id qk7mr8760287pbc.1.1328017294787; Tue, 31 Jan 2012 05:41:34 -0800 (PST) Path: lh20ni244957pbb.0!nntp.google.com!news1.google.com!postnews.google.com!m11g2000yqe.googlegroups.com!not-for-mail From: tonyg Newsgroups: comp.lang.ada Subject: Re: task abortion Date: Tue, 31 Jan 2012 05:25:46 -0800 (PST) Organization: http://groups.google.com Message-ID: <8a6f200f-cd2d-4270-a992-c4f31c573cc0@m11g2000yqe.googlegroups.com> References: <393dafce-883a-4b6c-82a6-1657de15d2f3@h12g2000yqg.googlegroups.com> <19pfl6kbf35z6.1ao0njyuiqbls.dlg@40tude.net> <94aa02cf-ccd3-4a08-999a-2bbe562f5bef@q8g2000yqa.googlegroups.com> <108b8a34-9dea-4d10-9560-239f5ac62a5f@w4g2000vbc.googlegroups.com> NNTP-Posting-Host: 195.58.145.51 Mime-Version: 1.0 X-Trace: posting.google.com 1328017294 4008 127.0.0.1 (31 Jan 2012 13:41:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 31 Jan 2012 13:41:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m11g2000yqe.googlegroups.com; posting-host=195.58.145.51; posting-account=28F2IwkAAACL1Z5nRC-dE7zuvWdbWC7P User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; 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-31T05:25:46-08:00 List-Id: On Jan 26, 4:47=A0pm, Anh Vo wrote: > 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 whi= le, > > > > 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 reaso= n > > > > 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 fr= eed > > > when the task is aborted. But if you have some globally allocated mem= ory, > > > semaphores etc, they all get lost unless freed by some local controll= ed > > > 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? Finalizat= ion is > > > such a thing. Abort-deferred stuff cannot be aborted. Note that syste= m 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 a= bort > > > any task. > > > > If you decided for aborting, you would have to redesign almost everyt= hing > > > and in an extremely careful way in order to make tasks logically abor= table. > > > That means to make continuation possible and meaningful after abortin= g 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 Thabjs Anh for that