comp.lang.ada
 help / color / mirror / Atom feed
* Suspension_Object problem
@ 2003-01-15 15:35 Philippe Laval
  2003-01-15 15:46 ` Jean-Pierre Rosen
  2003-01-15 19:02 ` Jeffrey Carter
  0 siblings, 2 replies; 3+ messages in thread
From: Philippe Laval @ 2003-01-15 15:35 UTC (permalink / raw)


The following program compiles without error in gnat 3.14p.
However the line "From H: P is now released" never shows up. What is
wrong?

-- File Susp_O.adb
with P_Pkg;
with H_Pkg;
procedure Susp_O is
begin
   null;
end Susp_O;
----------------------------------------------------------------------------------------------

-- File P_Pkg.ads
with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;
package P_Pkg is
   protected type Protected_Lock is
      procedure Set_Lock;
      procedure Release;
   private
      Lock : Suspension_Object;
   end Protected_Lock;

   type Lock_Access is access Protected_Lock;
   Attack_Lock : Lock_Access;

   task P;

end P_Pkg;

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

-- File P_Pkg.ads
package H_Pkg is
   task H;
end H_Pkg;
------------------------------------------------------------------------------------------------

-- File P_Pkg.adb
with Ada.Text_IO; use Ada.Text_IO;
package body P_Pkg is
   protected body Protected_Lock is
      procedure Set_Lock is
      begin
         Suspend_Until_True (Lock);
      end Set_Lock;

      procedure Release is
      begin
         Set_True (Lock);
      end Release;
   end Protected_Lock;

   task body P is
   begin
      Attack_Lock := new Protected_Lock;
      Put_Line ("P is being suspended.");
      Put_Line ("Waiting to be released by H...");
      Attack_Lock.Set_Lock;

      Put_Line ("P is now released.");
   end P;
end P_Pkg;
------------------------------------------------------------------------------------------------

-- File H_Pkg.adb
with Ada.Text_IO; use Ada.Text_IO;
with P_Pkg;
package body H_Pkg is
   task body H is
   begin
      delay 1.0;
      P_Pkg.Attack_Lock.Release;
      Put_Line ("From H : P is released now!");
   end H;
end H_Pkg;
------------------------------------------------------------------------------------------------

Philippe Laval
Observatoire Oc�anologique
F-06234 Villefranche-sur-Mer CEDEX
laval@obs-vlfr.fr




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-15 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-15 15:35 Suspension_Object problem Philippe Laval
2003-01-15 15:46 ` Jean-Pierre Rosen
2003-01-15 19:02 ` Jeffrey Carter

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