Waitable Timer Object: 80 secs early in a day

Waitable Timer Object: 80 secs early in a day

Post by Eberhard S » Sat, 28 May 2005 21:47:44


I'm using a Waitable Timer Object in the following way:

- Set the timer to an absolute time t0
- when timer wakes up, trigger an action, and set the timer again to an
absolute time t0 + 1 day
- repeat

(Actually, we take daylight savings time into account; since the Waitable
Timer Object uses UTC for absolute time, we cannot set the timer to wake up
periodically right from the start.)

I have noticed that for the second wake-up time (t +
1 day), the timer typically wakes up 80 to 90 seconds /early/.

Now, I'm perfectly aware that Windows XP is not a real-time OS, but a
deviation of 80 to 90 seconds seems like a lot to me.

Is this behaviour to be expected? Are there any strategies to improve the
accuracy?

Since the deviation seems to be at least loosely proportional to the wakeup
time span, I thought of the following algorithm: Set the next wakeup time
to

t0 + 1 day - 5 minutes

and set it again to

t0 + 1 day

when the timer wakes up. That way the deviation should become smaller,
because the overall span is only 5 minutes instead of 1 day.

What do you think?
 
 
 

Waitable Timer Object: 80 secs early in a day

Post by Alexander » Sun, 29 May 2005 13:19:13

Note that this is exactly 1/1000 of a day.

How do you calculate your target time? If your calculation is correct, I'd
suspect Windows bug.

 
 
 

Waitable Timer Object: 80 secs early in a day

Post by Eberhard S » Sun, 29 May 2005 18:00:05


Thanks for your input.

If we convert the FILETIME we calculated to a human-readable SYSTEMTIME
(via FileTimeToSystemTime), we can verify that the calculated time is
correct.