comp.lang.ada
 help / color / mirror / Atom feed
* Strange behaviour of delay in Windows
@ 2010-10-07 17:35 Michael Bode
  2010-10-10 10:02 ` michael bode
  2010-10-26  1:08 ` Yannick Duchêne (Hibou57)
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Bode @ 2010-10-07 17:35 UTC (permalink / raw)


I would expect the delay statement to delay execution for the given
time. So with this code:

with  Ada.Text_Io; use Ada.Text_Io;
with Ada.Calendar; use Ada.Calendar;

procedure Testprog is
   T1, T2 : Time;
   D : Duration;
begin
   D := 1.0;
   T1 := Clock;
   delay D;
   T2 := Clock;
   Put_Line ("Expected delay:" & Duration'Image(D));
   Put_Line ("Actual delay:" & Duration'Image(T2-T1));
end Testprog;

I'd expect to get this result:

Expected delay: 1.000000000
Actual delay: 1.000239000

But on one Windows machine (a Vostro MT 220, Windows XP) I get an actual
delay of about 2.7s instead. I tried with GNAT GPL 2008 and 2009. There
was no noticeable CPU load during the test. To make things more
interesting, a different machine (Vostro MT 230, same RAM, same CPU, same
Windows XP version) works as expected. And to make things even more
interesting, the Vostro MT 220 normaly lives in the lab. When I found
this bug I carried it over to my office to check things. In the office
it worked ok. Back to the lab and I got the 2.7s, most of the time. A
couple of times I got 1.0xxx seconds. 

Then I compiled the program statically linked on Debian, put a Ubuntu
Live CD in the machine and tried my program. Result was dozens of times
as printed above: 1.000xxx seconds.

Any ideas?



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

* Re: Strange behaviour of delay in Windows
  2010-10-07 17:35 Strange behaviour of delay in Windows Michael Bode
@ 2010-10-10 10:02 ` michael bode
  2010-10-11 19:00   ` Adam Beneschan
  2010-10-26  1:08 ` Yannick Duchêne (Hibou57)
  1 sibling, 1 reply; 5+ messages in thread
From: michael bode @ 2010-10-10 10:02 UTC (permalink / raw)


Am 07.10.2010 19:35, schrieb Michael Bode:

My regular news server was down. Looks like it is delivering old
postings now.



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

* Re: Strange behaviour of delay in Windows
  2010-10-10 10:02 ` michael bode
@ 2010-10-11 19:00   ` Adam Beneschan
  2010-10-11 19:05     ` Vinzent Hoefler
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Beneschan @ 2010-10-11 19:00 UTC (permalink / raw)


On Oct 10, 3:02 am, michael bode <m.g.b...@web.de> wrote:
> Am 07.10.2010 19:35, schrieb Michael Bode:
>
> My regular news server was down. Looks like it is delivering old
> postings now.

Maybe your news server was using a "delay" statement on Windows.

                       -- Adam



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

* Re: Strange behaviour of delay in Windows
  2010-10-11 19:00   ` Adam Beneschan
@ 2010-10-11 19:05     ` Vinzent Hoefler
  0 siblings, 0 replies; 5+ messages in thread
From: Vinzent Hoefler @ 2010-10-11 19:05 UTC (permalink / raw)


On Mon, 11 Oct 2010 21:00:50 +0200, Adam Beneschan <adam@irvine.com> wrote:

> On Oct 10, 3:02 am, michael bode <m.g.b...@web.de> wrote:
>> Am 07.10.2010 19:35, schrieb Michael Bode:
>>
>> My regular news server was down. Looks like it is delivering old
>> postings now.
>
> Maybe your news server was using a "delay" statement on Windows.

LOL. That was a good one.


Vinzent.

-- 
There is no signature.



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

* Re: Strange behaviour of delay in Windows
  2010-10-07 17:35 Strange behaviour of delay in Windows Michael Bode
  2010-10-10 10:02 ` michael bode
@ 2010-10-26  1:08 ` Yannick Duchêne (Hibou57)
  1 sibling, 0 replies; 5+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2010-10-26  1:08 UTC (permalink / raw)


Le Thu, 07 Oct 2010 19:35:36 +0200, Michael Bode <m.g.bode@web.de> a écrit:

Unless the compiler conforms to the Real-Time Annex D, this accuracy is  
implementation defined, which you can understand as “see the compiler  
manual instead of the reference” or alternatively as “you cannot assert  
anything”. This all said in 9.6(20) of the Ada 2005 RM :

    The time base associated with relative delays is as defined in D.9,
    “Delay Accuracy” or is implementation defined.

I know Dmitry Kazavov may have something to say about tasking and timing  
in the Windows operating system.

To push the test further, did you tried a “delay until …” statement, just  
to see ?

> I would expect the delay statement to delay execution for the given
> time. So with this code:
>
> with  Ada.Text_Io; use Ada.Text_Io;
> with Ada.Calendar; use Ada.Calendar;
>
> procedure Testprog is
>    T1, T2 : Time;
>    D : Duration;
> begin
>    D := 1.0;
>    T1 := Clock;
>    delay D;
>    T2 := Clock;
>    Put_Line ("Expected delay:" & Duration'Image(D));
>    Put_Line ("Actual delay:" & Duration'Image(T2-T1));
> end Testprog;
>
> I'd expect to get this result:
>
> Expected delay: 1.000000000
> Actual delay: 1.000239000
>
> But on one Windows machine (a Vostro MT 220, Windows XP) I get an actual
> delay of about 2.7s instead. I tried with GNAT GPL 2008 and 2009. There
> was no noticeable CPU load during the test. To make things more
> interesting, a different machine (Vostro MT 230, same RAM, same CPU, same
> Windows XP version) works as expected. And to make things even more
> interesting, the Vostro MT 220 normaly lives in the lab. When I found
> this bug I carried it over to my office to check things. In the office
> it worked ok. Back to the lab and I got the 2.7s, most of the time. A
> couple of times I got 1.0xxx seconds.
>
> Then I compiled the program statically linked on Debian, put a Ubuntu
> Live CD in the machine and tried my program. Result was dozens of times
> as printed above: 1.000xxx seconds.
>
> Any ideas?


-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.



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

end of thread, other threads:[~2010-10-26  1:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-07 17:35 Strange behaviour of delay in Windows Michael Bode
2010-10-10 10:02 ` michael bode
2010-10-11 19:00   ` Adam Beneschan
2010-10-11 19:05     ` Vinzent Hoefler
2010-10-26  1:08 ` Yannick Duchêne (Hibou57)

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