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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,470e89e7a6575920 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!bnewspeer01.bru.ops.eu.uu.net!emea.uu.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Periodic tasks - organization Date: Thu, 17 Jul 2008 20:31:11 +0100 Organization: Pushface Message-ID: References: <86589099-2e4e-4b7d-ace0-6f1f864a3fa2@y21g2000hsf.googlegroups.com> <6e0jbhF4o43oU1@mid.individual.net> <561c8fa7-f26d-49a3-b54c-229c20462c04@r66g2000hsg.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.demon.co.uk 1216323072 27631 62.49.19.209 (17 Jul 2008 19:31:12 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 17 Jul 2008 19:31:12 +0000 (UTC) Cancel-Lock: sha1:8bZgci9IYH0NaknWLWL0s6SB578= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (darwin) Xref: g2news2.google.com comp.lang.ada:6927 Date: 2008-07-17T20:31:11+01:00 List-Id: Anh Vo writes: > On Jul 16, 2:38�pm, Simon Wright wrote: >> Anh Vo writes: >> > It is even better to use periodic timers built on top >> > Ada.Real_Time.Timing_Events. Then, explicit tasks are not needed. >> >> Only 'better' if that solution meets a need that's not met by the >> straightforward approach. >> >> I see that Timing Event Handlers are meant to be executed directly by >> the protected handler operation >> (http://www.adaic.com/standards/05rm/html/RM-D-15.html25/2), so >> clearly the intent is that some task should be released by the action >> of the handler (similar to interrupts). So you still need explicit >> tasks! just replacing a delay with a blocking wait on the PO which >> will be triggered by the timing event -- a lot of complication. > > Making two explicit tasks involves overhead for sure. It is true that > using PO construct is more complex than using two independent tasks. > Furthermore, an explicit task is not needed once the timer is started > initially. But there are limits on what is permissible within a protected procedure, are there not? Not sure what you mean by "once the timer is started initially", timing events are one-shot (once the event fires, it's cleared). In the code below (my first try, excuse any stupidities & the need for 'Unresricted_Access) I reckon there are 11 extra logical LOC ... with Ada.Real_Time.Timing_Events; with Ada.Text_IO; use Ada.Text_IO; procedure Periodic is protected Po is procedure Handler (E : in out Ada.Real_Time.Timing_Events.Timing_Event); entry Wait; private Released : Boolean := False; end Po; protected body Po is procedure Handler (E : in out Ada.Real_Time.Timing_Events.Timing_Event) is begin Released := True; end Handler; entry Wait when Released is begin Released := False; end Wait; end Po; Ev : Ada.Real_Time.Timing_Events.Timing_Event; task T is end T; task body T is begin Put_Line ("setting the Event"); New_Line; Ada.Real_Time.Timing_Events.Set_Handler (Ev, In_Time => Ada.Real_Time.To_Time_Span (1.0), Handler => Po.Handler'Unrestricted_Access); Po.Wait; Put_Line ("t released."); end T; begin null; end Periodic;