comp.lang.ada
 help / color / mirror / Atom feed
From: "Anh Vo" <anhvofrcaus@gmail.com>
Subject: Re: Designing Timers using Ada.Real_Time.Timing_Events package
Date: 26 Mar 2006 21:01:13 -0800
Date: 2006-03-26T21:01:13-08:00	[thread overview]
Message-ID: <1143435673.255301.186540@u72g2000cwu.googlegroups.com> (raw)
In-Reply-To: <0mae22lshe5nee8pt8h7seussloebv07g3@4ax.com>


Dennis Lee Bieber wrote:
> On 26 Mar 2006 15:53:38 -0800, "Anh Vo" <anhvofrcaus@gmail.com>
> 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




  parent reply	other threads:[~2006-03-27  5:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-25 20:03 Designing Timers using Ada.Real_Time.Timing_Events package Anh Vo
2006-03-25 20:58 ` Dmitry A. Kazakov
2006-03-26  5:39   ` Anh Vo
2006-03-26 12:58     ` Dmitry A. Kazakov
2006-03-26 16:18       ` Anh Vo
2006-03-26 18:22         ` Dmitry A. Kazakov
2006-03-26 19:43           ` Anh Vo
     [not found]             ` <3itd22hcekts5lsojdqjnn966bbvc8fckh@4ax.com>
2006-03-26 23:53               ` Anh Vo
     [not found]                 ` <0mae22lshe5nee8pt8h7seussloebv07g3@4ax.com>
2006-03-27  5:01                   ` Anh Vo [this message]
     [not found]                     ` <5vse22h4mc1och27s0nkbv986csi2rorki@4ax.com>
2006-03-28  0:07                       ` Anh Vo
2006-03-27  7:49             ` Dmitry A. Kazakov
2006-03-27 18:14               ` Dmitry A. Kazakov
2006-03-27 22:00                 ` Anh Vo
2006-03-28  7:51                   ` Dmitry A. Kazakov
2006-03-28 16:00                     ` Anh Vo
2006-03-26  7:59 ` Martin Krischik
2006-03-26 15:50   ` Anh Vo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox