comp.lang.ada
 help / color / mirror / Atom feed
From: Reto Buerki <reet@codelabs.ch>
Subject: Barrier re-evaluation issue with GNAT 4.3.2
Date: Thu, 24 Sep 2009 19:02:14 +0200
Date: 2009-09-24T19:02:14+02:00	[thread overview]
Message-ID: <h9g8mf$v4f$1@news.eternal-september.org> (raw)

Hi,

The test code below implements a simple alarm clock which should wakeup
the task waiting on the "Wait_For_Wakeup" entry.

With GNAT 4.3.2 on Debian/stable this does not work. The main task
remains queued on the entry even though the Wakeup-handler is invoked
correctly by the Timing_Event.

Compiling the same code with GNAT 4.4.1-5 (on Debian/SID) or GNAT GPL
2009 leads to the expected behavior: The main task terminates after the
alarm has fired. This indicates a bug in FSF GNAT 4.3.2.

--------------------

with Ada.Text_IO;
with Alarm_Clock;

procedure Main is
   My_Alarm : Alarm_Clock.Alarm_Type;
begin
   Ada.Text_IO.Put_Line ("Starting alarm ...");
   My_Alarm.Start;

   Ada.Text_IO.Put_Line ("Waiting for alarm ...");
   My_Alarm.Wait_For_Wakeup;

   Ada.Text_IO.Put_Line ("ALARM!!");
end Main;

--------------------

with Ada.Real_Time.Timing_Events;

package Alarm_Clock is

   use Ada.Real_Time;

   protected type Alarm_Type is
      procedure Start;
      procedure Wakeup (Event : in out Timing_Events.Timing_Event);
      entry Wait_For_Wakeup;
   private
      Timer       : Timing_Events.Timing_Event;
      Alarm_Fired : Boolean := False;
   end Alarm_Type;

end Alarm_Clock;

--------------------

package body Alarm_Clock is

   protected body Alarm_Type is
      procedure Start is
      begin
         Timer.Set_Handler (In_Time => Seconds (3),
                            Handler => Wakeup'Access);
      end Start;

      procedure Wakeup (Event : in out Timing_Events.Timing_Event) is
      begin
         Alarm_Fired := True;
      end Wakeup;

      entry Wait_For_Wakeup when Alarm_Fired is
      begin
         null;
      end Wait_For_Wakeup;
   end Alarm_Type;

end Alarm_Clock;

--------------------

Avoiding the usage of Ada.Real_Time.Timing_Events by implementing a
delaying task does not solve the problem. So it's not Ada real time related.

We suspect that the Alarm_Fired-barrier of the Wait_For_Wakeup entry is
not correctly re-evaluated after the Wakeup()-handler has been called.

Switching the compiler is a solution we consider as last resort.

Does anybody know what the actual problem could be? Is there a different
way to implement the same functionality or a "workaround" which would
avoid this problem?

Thanks in advance,
- reto



             reply	other threads:[~2009-09-24 17:02 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-24 17:02 Reto Buerki [this message]
2009-09-24 17:47 ` Barrier re-evaluation issue with GNAT 4.3.2 Dmitry A. Kazakov
2009-09-25  8:50   ` Brad Moore
2009-09-25  9:17     ` Dmitry A. Kazakov
2009-09-25  9:57       ` Ludovic Brenta
2009-09-25 10:31         ` Dmitry A. Kazakov
2009-09-25 11:23       ` Jean-Pierre Rosen
2009-09-28 10:41         ` Reto Buerki
2009-09-25 17:06       ` Brad Moore
2009-09-25 18:42         ` Dmitry A. Kazakov
2009-09-25 19:39           ` Brad Moore
2009-09-28 10:18   ` Reto Buerki
2009-09-25 15:56 ` John B. Matthews
2009-09-26 14:23   ` John B. Matthews
2009-09-28 10:28   ` Reto Buerki
2009-09-28 12:39     ` John B. Matthews
2009-09-28 13:25       ` Reto Buerki
2009-09-28 14:05         ` Reto Buerki
2009-09-28 18:38           ` Jeffrey R. Carter
2009-09-28 18:51             ` Dmitry A. Kazakov
2009-09-29  8:37               ` Reto Buerki
2009-09-28 21:13             ` Robert A Duff
2009-09-28 22:28               ` Jeffrey R. Carter
2009-10-10  5:41                 ` Randy Brukardt
2009-09-29  8:30             ` Reto Buerki
2009-09-29 15:06               ` John B. Matthews
2009-09-30 14:12                 ` Reto Buerki
2009-09-30 15:59                   ` John B. Matthews
2009-10-01 16:12                     ` John B. Matthews
2009-10-01 17:17                       ` Anh Vo
2009-10-02  2:26                         ` John B. Matthews
replies disabled

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