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,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7897733b1978b6a4 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.39.100 with SMTP id o4mr5043146pbk.0.1321688249034; Fri, 18 Nov 2011 23:37:29 -0800 (PST) MIME-Version: 1.0 Path: h5ni8683pba.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Freezing a task Date: Sat, 19 Nov 2011 07:37:26 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <32992849.648.1321544004241.JavaMail.geo-discussion-forums@vbmh5> Reply-To: anon@anon.org NNTP-Posting-Host: nlMUwqQAuqWx4d8ymf1dIg.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: IBM NewsReader/2 2.0 Xref: news1.google.com comp.lang.ada:18978 Date: 2011-11-19T07:37:26+00:00 List-Id: In some programming circles, the "main procedure" is also called the parent. And tasks without the "Terminate" statement some times will continue to execute, even when the parent aka "main procedure" dies. One reason for the disliked "Abort" statement. Two examples of tasks that do not contain "terminate" statement are servers and tasking device drivers. For the task to stop, these tasks must be setup to handle a "Stop" type of call to interrupt the process or another routine may have to use the "Abort" statement. Of course, there always the "Ada.Synchronous_Task_Control but that's a more involved process. And a fully functional version of the package Ada.Asynchronous_Task_Control is not supply in the general release of GNAT version of Ada. In my example the one thing I did not include was the single to multiple layers of exceptions that could be added. In , Anh Vo writes: >On Nov 17, 11:24=A0pm, a...@att.net wrote: >> -- >> -- =A0Complete Program >> -- >> >> with Text_IO ; >> >> procedure u is >> >> =A0 use Text_IO ; >> >> =A0 task type test is >> =A0 =A0 =A0 entry Start ; =A0 =A0-- initialize and start task >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- and task can die if par= >ent stops >> >> =A0 =A0 =A0 entry Wait ; =A0 =A0 -- Send task to sleep for a while >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- and task can die if par= >ent stops >> >> =A0 =A0 =A0 entry Continue ; -- wake up task >> =A0 =A0 =A0 entry Stop ; =A0 =A0 -- stops and kill task >> =A0 end test ; >> >> =A0 task body test is >> >> =A0 =A0 =A0 Count : Integer ; >> =A0 =A0 begin >> =A0 =A0 =A0 -- =A0Initialize task >> =A0 =A0 =A0 Count :=3D 0 =A0; >> =A0 =A0 =A0 Outer_Loop : loop >> =A0 =A0 =A0 =A0 select >> =A0 =A0 =A0 =A0 =A0 -- =A0start task >> =A0 =A0 =A0 =A0 =A0 accept Start ; >> =A0 =A0 =A0 =A0 =A0 =A0 Put_Line ( "Start" ) ; >> >> =A0 =A0 =A0 =A0 =A0 =A0 Main_Loop : loop >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 select >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- =A0pause task >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 accept Wait ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Put_Line ( "Wait" ) ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 New_Line ; >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 select >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- =A0sofware wake up task >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 accept Continue ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Put_Line ( "Continue" ) ; >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- =A0software exit while in wait mod= >e >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 or >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 accept Stop ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Put_Line ( "Stop" ) ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit Outer_Loop ; >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- =A0exit if parent fails while in w= >ait mode >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 or >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 terminate ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end select ; >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- =A0software exit (abort) while in normal >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- =A0execution mode >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 or >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 accept Stop ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Put_Line ( "Stop" ) ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit Outer_Loop ; >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 else >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- - - - - - - - - - - -- >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- =A0Main Tasking Code =A0-- >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- - - - - - - - - - - -- >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Put ( "Testing" ) ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Put ( Integer'Image ( Count ) ) ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 New_Line ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Count :=3D Count + 1 ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 end select ; >> =A0 =A0 =A0 =A0 =A0 end loop Main_Loop ; >> >> =A0 =A0 =A0 =A0 -- =A0exit if parent fails >> =A0 =A0 =A0 =A0 or >> =A0 =A0 =A0 =A0 =A0 terminate ; >> =A0 =A0 =A0 =A0 end select ; >> =A0 =A0 =A0 end loop Outer_Loop ; >> =A0 =A0 =A0 Put_Line ( "Task has Terminated" ) ; >> =A0 =A0 end test ; >> >> =A0testing_task =A0 =A0 =A0: test ; >> >> begin >> =A0 Put_Line ( "Start Tasking" ) ; >> =A0 New_Line ; >> =A0 -- >> =A0 testing_task.Start ; >> =A0 delay ( 0.01 ) ; >> =A0 testing_task.Wait ; >> =A0 delay ( 1.0 ) ; >> =A0 testing_task.Continue ; >> =A0 delay ( 0.01 ) ; >> =A0 testing_task.Wait ; >> =A0 -- >> =A0 delay ( 1.0 ) ; >> =A0 testing_task.Stop ; >> =A0 delay ( 0.5 ) ; >> =A0 New_Line ; >> end u ; > >I am not sure what was meant by couple of annotated comments >mentioning parent fails. Normally, tasks are declared at library >level. Thus, they will terminate when the main program terminates. In >this particular example, the task will terminate when the main >procedure terminates. > >Anh Vo