System clock is slow
Hi,
I am using Debian / knoppix 3.4 on a laptop. Linux kernel 2.4.26. My Hardware Clock is accurate. My System Time syncs to the (correct) Hardware Clock setting when I start the computer, but then quickly starts losing time. The System Time seems to be about 15 minutes slower by the end of the day. Again, the Hardware Clock (time kept by CMOS) is OK. It is the System Time (kep t by the kernel) that is wrong. Why is this happening? How can I get the kernel to keep accurate time? Thank you for any help you can provide. |
this is confusing cause as i understand it the kernel uses time stamp counter (hardware)
not real-time clock (software) so there are no interupts thus no latency ???????? this should mean the clock should be rock solid. what kind of cpu is this ???? |
The CPU is a Pentium III. Not sure what difference that would make.
To demonstrate that the System Time is indeed slower than the Hardware Clock: $ hwclock --show Sat Sep 4 19:29:43 2004 -0.006329 seconds $ date Sat Sep 4 19:26:21 EDT 2004 $ The Hardware Clock is accurate. How can I get the system time to be as well? Thanks for any help anyone can provide. |
The only suggestion I have is to set up a Cron Job that runs the command
Code:
0 * * * * "/sbin/hwclock --hctosys I hope this helps --Ian |
Quote:
|
Solved problem with adjtimex
I beleive I have solved the problem. The System Time is calibrated with a program called adjtimex, which I didnt have installed.
After installing adjtimex, I have configured it to run in the startup scripts and calibrated it to adjust the System Time to run at the correct speed. See man adjtimex(8) for details. This is the right solution; the kernel now keeps correct time. Syncing hourly to the hardware clock would have been a poor solution; the time would have been inaccurate betwen syncs, and in addition it is bad form to change the System Time in a running system as this can cause problems with other processes running on the system. Using ntpd was not an option in this case since the machine is only intermitantly connected to the net. |
Re: Solved problem with adjtimex
Quote:
|
On some notebooks the clock won't play nice with apm
enabled ... my machine had erratic timing, too, until I switched from APM to ACPI. Cheers, Tink |
another good program for keeping the system clock at the right time is rdate
maybe you could check it up |
update on system time problems
Hi,
Thanks for the various suggestions. Just wanted to update the thread with the latest on my System Time issues. Using adjtimex, I was able to set up the kernel's time variables more accurately. This has got system time to be much more accurate... now it's off by usually 8-10 seconds a day rather than 8-10 minutes. I haven't been able to get it to run more accurately than that; the remaining variance seems to be irreguar, sometimes fast sometimes slow. Also note that adjtimex --compare produces wildly innaccurate and inconsisten results on my system. These problems may be due to apmd, which I am running (I use apm because acpi caused more serious problems on my system). Some other people seem to think it could be the battery monitor application. Some more information on laptop time problems under linux is discussed here: http://tinyurl.com/6t5nl Setting up ntpd and a script to run it when possible as trickykid suggested might be the best solution for the remaining innaccuracy. I may work on this when I have more time. Really though, if apmd is at fault the program should be fixed. |
Did you consider/evaluate the apm vs acpi possibility?
Cheers, Tink |
Quote:
Time-stamp counter measures cpu cycles and not "time". For example, two hundred million cycles on a 200 MHz processor is equivalent to one second of real time, while the same number of cycles on a 400 MHz processor is only one-half second of real time. Thus faster proccessor has finer grained time accuracy access is through model specific registers.. Intel started making it available for programmers Intel chips have 2 registers AMD chips have 4 some cyrix chips dont do RDTSC some do even as they all identify themselves to the kernel as i686 each chip is handled differently and |o| sometimes the kernel has buggs. (i can't believe i said that) from the kernel mailing list concerning this subject: Some web pages say "Works Best with IE 4.0" Linux will have to say "Works Best with Intel Inside!". add to this mix the fact that linux people generally are running kernels compiled specifically to run on intel cpus manufactured in 1980 for some strange reason. If the processor does not have Time-stamp counter available then the kernel will have to use interupts that can well -- get interupted. |
All times are GMT -5. The time now is 09:51 AM. |