Spectrum Logo
A non-profit publication of the Office of the University Relations of Virginia Tech,
including The Conductor, a special section of the Spectrum printed 4 times a year
How Does the Computer Clock Work?

Spectrum Volume 20 Issue 03 - September 11, 1997

Every personal computer contains two clocks: a built-in hardware clock and a virtual clock. The hardware clock (real-time clock) runs whether the system is on or off. The virtual clock (system clock) is set to the real-time clock when the computer is turned on and exists only while the computer is operating. While the computer is up and running, the two clocks run independent of each other.

The system clock is a 24-hour timer and has no real concept of days, whereas the real-time clock tracks the time and date. In fact, the system clock has no concept of traditional hours, minutes, and seconds. It merely increments a counter 18.2 times per second. The operating system, which is dependent upon the system clock for the time, converts the counter into hours, minutes and seconds.

As for the date, the operating system reads the real-time clock via the BIOS during initialization, then tracks the date independently based on the virtual-system clock rolling over midnight.

The real-time clocks used in today's personal computers do not track centuries; only years, such as '96, are tracked. After Dec. 31, 1999, the real-time clock merely indicates year '00. It is the BIOS's responsibility to track the century and preserve that information in the real-time clock's nonvolatile memory. The BIOS assumes that the years 1900 through 1979 cannot occur, so when the year is within 00-79 and the century information is 19, the BIOS sets the century information to 20. If the BIOS does not track the century, the operating system will be given an invalid year and most likely will assume 1980. (Microsoft operating systems do not support dates earlier than 1980.)

Caveats

Since the two clocks run independently, the real-time clock can be set to any nonsensical value and the operating system will not notice. Such will occur Jan. 1, 2000 if your system does not support the year 2000. As long as the system is running, the operating system will correctly support the occurrence of the year 2000. Problems will occur, however, when the system is rebooted or powered off, then on. This is the first caveat: setting the date and time just before the year 2000 and just letting the new year occur is not a valid test. The real-time clock may be invalid, but the date according to the operating system will be correct. The system must be powered off, then on to complete this type of test, but there is still a catch.

The second caveat applies when the operating system is used to set the date and time. The system clock will always be set by the operating system. However, not all operating systems will concurrently set the real-time clock with the system clock. In this scenario, the above methodology may cause a system that correctly supports the year 2000 to fail if the operating system does not set the real-time clock as well.