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,5b15c37c5d0c986f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!u72g2000cwu.googlegroups.com!not-for-mail From: "Anh Vo" Newsgroups: comp.lang.ada Subject: Re: Designing Timers using Ada.Real_Time.Timing_Events package Date: 26 Mar 2006 21:01:13 -0800 Organization: http://groups.google.com Message-ID: <1143435673.255301.186540@u72g2000cwu.googlegroups.com> References: <1143317010.868435.251190@v46g2000cwv.googlegroups.com> <1d4yew2i587h5.1h8dilwbda4zv.dlg@40tude.net> <1143351567.528574.297850@z34g2000cwc.googlegroups.com> <1fiau0e4pe84o$.gulfgysczk5i$.dlg@40tude.net> <1143389936.844624.243020@i40g2000cwc.googlegroups.com> <1143402228.182836.29570@v46g2000cwv.googlegroups.com> <3itd22hcekts5lsojdqjnn966bbvc8fckh@4ax.com> <1143417218.070618.302820@i39g2000cwa.googlegroups.com> <0mae22lshe5nee8pt8h7seussloebv07g3@4ax.com> NNTP-Posting-Host: 71.146.81.142 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1143435678 7392 127.0.0.1 (27 Mar 2006 05:01:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 27 Mar 2006 05:01:18 +0000 (UTC) In-Reply-To: <0mae22lshe5nee8pt8h7seussloebv07g3@4ax.com> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: u72g2000cwu.googlegroups.com; posting-host=71.146.81.142; posting-account=JVr7Xg0AAAAI3MbuARxMmvWLmA7qdJMx Xref: g2news1.google.com comp.lang.ada:3646 Date: 2006-03-26T21:01:13-08:00 List-Id: Dennis Lee Bieber wrote: > On 26 Mar 2006 15:53:38 -0800, "Anh Vo" > declaimed the following in comp.lang.ada: > > > > > Does it mean that as long as the main task is not involved in the > > deadlock, the main program should operate, not hung? > > > I was speaking generally, not specific to any particular code. > > Unfortunately, the code in your original post isn't useful to me; I > only have GNAT/GPS GPL [at least I've finally moved up to that; last > week I was still using GNAT 3.15p] -- I get: > > timers_test1.ads:1:06: "Ada.Real_Time.Timing_Events" is not a predefined > library unit > > Which, as you comment somewhere in the chain, is not (yet) in the > GNAT release. In my original post I did mention in the PS that gcc-4.2.0 was needed to compile these codes. GNAT-GPL and gcc-4.1.0 do not implement Timing_Events yet. > However, I don't find a "main program" in your original post; just a > lot of packages, so I can't even review it visually to figure out what > may be happening. I will post entire codes including the main subprogram after you building and installing gcc-4.2.0. > > with Ada.Real_Time; > > with Ada.Text_Io; > > package body Timers_Test2 is > > > > use Ada; > > use Text_Io; > > > > Periodic_Time : constant Real_Time.Time_Span := Real_Time.Milliseconds > > (3000); > > Periodic_Timer : aliased Periodic_Timer_Type; > > > > procedure Update ( > > Observer : access Periodic_Timer_Type) is > > begin > > Put_Line ("The state Timer just expires. Do some thing here"); > > Basic_Timer.Start (Periodic_Timer); --!!! causing deadlock > > Is that a typo? The package is Basic_TimerS Yes, it is clearly a typo. However, it should be OK because Ada is a case insensitive language. > And what use is "Observer" (I suspect you should be calling > basic_timers.start(Observer); Both Observer and Periodic_Timer are the same. > > end Update; > > > > procedure Start is > > begin > > Basic_Timers.Set (Periodic_Timer'access, Periodic_Time); > > Basic_Timers.Start (Periodic_Timer'access); > > end Start; > > > > procedure Shutdown is > > begin > > Basic_Timers.Cancel (Periodic_Timer'access); > > end Shutdown; > > > > end Timers_Test2; > > > > package body Basic_Timers is > > > > protected body Events is > > procedure Handler ( > > Event : in out Real_Time.Timing_Events.Timing_Event) is > > begin > > The_Timer.Started := False; > > Update (The_Timer); > > end Handler; > > end Events; > > I don't like the fact that you are using a "global" "the_timer" > rather than somehow passing it in -- perhaps as an extension to > timing_event... As mentioned before I would like to design a generic timer used for different purposes. > Half the code seems to assume that there could be multiple timers > that may need to be handled -- and then we get a this, which only knows > about one instance... This is the intention. Otherwise, there is no need for this package since the Timing_Events can used directly. > Maybe reverse your type definition; rather than embedding a > timing_event inside your timer_type, extend timing_event with the other > parameters... Then you'd have > > event.started := false; > update(event); This is needed so the timer can be started for the next cycle. > This is all hypothesis, since I can not compile even the little you > supplied (and don't have a main program). (Well, compile with complaints > about ada.real_time-timing_events) No, it is for real since I compiled and run it. Otherwise, I would not dare to post the question in the first place. As mentioned earlier, you need gcc-4.2.0. Any thing else will not do it. By the way, I suggest reading a soon approved Ada 2005 Reference Manual and Ada 2005 Rationale at www.adaic.org specially package Ada.Real_Time.Timing_Events. AV