Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: delay until...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 9 Topic 5644 of 5831
Post > Topic >>

Re: delay until problem in Windows

by george.priv@[EMAIL PROTECTED] Apr 9, 2008 at 07:56 AM

On Apr 7, 3:25 am, "Dmitry A. Kazakov" <mail...@[EMAIL PROTECTED]
>
wrote:
> On Sun, 6 Apr 2008 20:10:38 -0700 (PDT), george.p...@[EMAIL PROTECTED]
 wrote:
> > On Apr 5, 6:51 pm, george.p...@[EMAIL PROTECTED]
 wrote:
>
> [...]
>
> > with Ada.Calendar;
> > use Ada.Calendar;
>
> I don't know the implementation of, but Ada.Calendar is a political
time,
> influenced by the time synchronization stuff. What happens if you
replace
> it by Ada.Real_Time?
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

You were right: so far the Real_Time version is running for 48 hours
without failing.  So that may be a workaround.

with Ada.Real_Time;
use Ada.Real_Time;
with Ada.Text_IO;
use Ada.Text_IO;

--with Ada.RealFormatting;
with Ada.Calendar.Formatting;

procedure Delay_RT is

   Start_Time  : Time              := Clock;
   Time_Failed : Time              := Start_Time;
   ST          : Ada.Calendar.Time := Ada.Calendar.Clock;
   FT          : Ada.Calendar.Time := ST;

   task Delay_Test_Tsk is
      entry Term;
   end Delay_Test_Tsk;

   task body Delay_Test_Tsk is

      DT            : constant Time_Span := Seconds (10); -- Desired
Delta T
      Time_For_Next :          Time      := Clock + DT;   -- Next
cycle
      Last          :          Time      := Clock;        -- Last
cycle clocked
      Fail_Count    :          Natural   := 0;

   begin

      while Fail_Count < 5 loop

         select
            accept Term;
            exit;
         or
            delay until Time_For_Next;
            declare
               Actual_Delta : Time_Span := Clock - Last;
            begin

               Last := Clock;
               Time_For_Next := Last + DT;

               Put_Line("Actual Delay: " & Duration'Image(To_Duration(
                        Actual_Delta))
                  & ", Running (h):"
                  & Duration'Image(To_Duration(Clock - Start_Time)/
3600.0));
               if Actual_Delta < DT or Actual_Delta > (DT +
Seconds(1)) then
                  if Fail_Count = 0 then
                     Time_Failed := Clock;
                     FT := Ada.Calendar.Clock;
                  end if;
                  Fail_Count := Fail_Count + 1;
               else
                  Fail_Count := 0;
               end if;
            end;

         end select;

      end loop;

      Put_Line("Started at:" & Ada.Calendar.Formatting.Image(ST));

      if Time_Failed /= Start_Time then
         Put_Line("Failed at :" & Ada.Calendar.Formatting.Image(FT));
         Put_Line("Failed after  :" & Duration'Image(To_Duration(
                  Time_Failed -
                  Start_Time)));
      end if;

   end Delay_Test_Tsk;

   Line : String (1 .. 80);
   Last : Natural;

begin
   loop
      Get_Line(Line, Last);
      exit when Line(1) = 'q' or Line(1) = 'Q';
   end loop;
   Delay_Test_Tsk.Term;
end Delay_RT;
 




 9 Posts in Topic:
delay until problem in Windows
george.priv@[EMAIL PROTEC  2008-04-05 15:51:24 
Re: delay until problem in Windows
Jacob Sparre Andersen <  2008-04-06 23:04:13 
Re: delay until problem in Windows
george.priv@[EMAIL PROTEC  2008-04-06 20:10:38 
Re: delay until problem in Windows
"Dmitry A. Kazakov&q  2008-04-07 09:25:54 
Re: delay until problem in Windows
george.priv@[EMAIL PROTEC  2008-04-06 20:32:34 
Re: delay until problem in Windows
george.priv@[EMAIL PROTEC  2008-04-07 07:43:43 
Re: delay until problem in Windows
george.priv@[EMAIL PROTEC  2008-04-07 07:51:30 
Re: delay until problem in Windows
"Alex R. Mosteo"  2008-04-08 13:02:42 
Re: delay until problem in Windows
george.priv@[EMAIL PROTEC  2008-04-09 07:56:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 1:21:43 CDT 2008.