Why does the clock on my laptop keep incorrect time?

Why does the clock on my laptop keep incorrect time?

Your laptop has two or more clocks, and FreeBSD has chosen to use the wrong one.

Run dmesg(8), and check for lines that contain Timecounter. The last line printed is the one that FreeBSD chose, and will almost certainly be TSC.

    # dmesg | grep Timecounter
    Timecounter "i8254"  frequency 1193182 Hz
    Timecounter "TSC"  frequency 595573479 Hz

You can confirm this by checking the kern.timecounter.hardware sysctl(3).

    # sysctl kern.timecounter.hardware
    kern.timecounter.hardware: TSC

The BIOS may modify the TSC clock--perhaps to change the speed of the processor when running from batteries, or going into a power saving mode, but FreeBSD is unaware of these adjustments, and appears to gain or lose time.

In this example, the i8254 clock is also available, and can be selected by writing its name to the kern.timecounter.hardware sysctl(3).

    # sysctl -w kern.timecounter.hardware=i8254
    kern.timecounter.hardware: TSC -> i8254

Your laptop should now start keeping more accurate time.

To have this change automatically run at boot time, add the following line to /etc/sysctl.conf.

    kern.timecounter.hardware=i8254


Home
FAQ