Erratic time behavior
Kyle Brost
kbrost at opentext.com
Wed Nov 2 20:22:55 UTC 2005
Hi,
I have recently taken a Linux 2.1 ES box, reformatted it and created a
Linux 3.0 ES box (machine is a dual PII 300MHz). Prior to the change in
OS the system ran without any problems. Now, I have a system that has
erratic time behavior and I'm looking for some advice.
I wrote a script and ran it and within the first minute, I get
interesting results.
---script---start---
#!/usr/bin/env perl
while(1)
{
print "Sleep: ";
print sleep(5);
print " -- ", scalar localtime(), " -- ";
print `hwclock`;
}
---script---end---
Sleep: 4 -- Wed Nov 2 13:19:15 2005 -- Wed 02 Nov 2005 01:19:13 PM MST
2.159954 seconds
Sleep: 5 -- Wed Nov 2 13:19:18 2005 -- Wed 02 Nov 2005 01:19:19 PM MST
-0.992030 seconds
Sleep: -8 -- Wed Nov 2 13:19:24 2005 -- Wed 02 Nov 2005 01:19:25 PM MST
-0.993252 seconds
Sleep: 19 -- Wed Nov 2 13:19:44 2005 -- Wed 02 Nov 2005 01:19:31 PM MST
-0.827775 seconds
Sleep: 6 -- Wed Nov 2 13:19:37 2005 -- Wed 02 Nov 2005 01:19:37 PM MST
-1.147800 seconds
Sleep: 5 -- Wed Nov 2 13:19:42 2005 -- Wed 02 Nov 2005 01:19:43 PM MST
-12.785016 seconds
Sleep: 5 -- Wed Nov 2 13:19:48 2005 -- Wed 02 Nov 2005 01:19:49 PM MST
-0.985043 seconds
Sleep: 9 -- Wed Nov 2 13:19:58 2005 -- Wed 02 Nov 2005 01:19:55 PM MST
-1.148049 seconds
Notice the values being returned by sleep (4,5,-8,19,6,5,5,9) and the
near constant 6 seconds on the hwclock call.
Why would I be seeing erratic sleep return values and date timestamps?
Using a stopwatch to time the sleeps shows that they are not always 5
seconds. Sometimes they return 2 or 3 seconds early.
Thanks,
Kyle Brost
----
More information about the redhat-list
mailing list