3

Why do I need to synchronize a time on my computer?

My wrist-watch gives no more than half a second error per year without using any NTP server. Why do I need to synchronize a computer with other computers?

Why isn't it enough to set a correct time once?

2
  • 2
    Who says you need to? Sep 14, 2012 at 3:01
  • 2
    My cheap wristwatch loses half a second a day. Sep 16, 2012 at 15:04

3 Answers 3

4

I understand that it is mostly a question of price/profitability. Let me explain: All timekeeping in computers happens through oscillators, electronic circuits which generate a signal at a certain frequency (usually in the range from some kHz to several MHz). However, no oscillator is 100% accurate, external influences like supply voltage, temperature, radiation, electromagnetic influences etc. all disturb the frequency which is generated. All of these can be more or less compensated (as quite precise digital wristwatches show), but this requires additional effort. Also, making it very accurate would require calibrating each motherboard individually (possibly even over a longer period of time).

Since exact timekeeping is not a high priority in common computers, computer motherboards are not highly optimized for this purpose, and thus the accuracy of the internal clocks (whether it be the "real-time clock" which keeps the time while the computer is off or the run-time clock provided by the processor) is limited.

Motherboard manufacturers have no incentive for adding additional circuitry or calibrating the oscillators to make to clock more accurate: for normal usage, the clock precision (on par with cheap wristwatches, 2-3 seconds off per month) is enough. For better accuracy, it's easy to sync to a NTP time server over the internet. For people who need very high accuracy or want to act as a NTP server, there exists special equipment (example) which receive the time from a atomic clock via DCF77 or GPS (yes, the GPS satellites have atomic clocks inside).

Ultimately, making a computer clock very accurate is just too expensive to have it built in to each and every computer, especially given the existing cheap solutions like NTP time servers. Windows for example syncs the time automatically from a Microsoft time server.

7

The Windows operating system clock starts out with the same value as the Real Time Clock whenever you reboot your computer, but from then on, it is updated completely independently of the RTC via periodic clock interrupts. Thus, over time (i.e. as the system runs), it is possible for the Windows operating system clock to get out of sync with the actual hardware RTC clock (i.e. the actual "wall clock" time).

This happens because as the system runs, certain software and operating system functions sometimes have to disable all interrupts causing the operating system to sometimes miss a clock interrupt. Most software that disable all interrupts (including the Windows operating system) don't keep interrupts disabled for very long (it's usually only for a VERY short period of time -- usually only a few microseconds (millionths of a second) at most), but because they DO disable all interrupts from time to time, clock ticks ARE unfortunately periodically lost, and over time, add up, causing the Windows operating system clock to sometimes differ considerably from the actual "wall clock" time (sometimes by several minutes or more, depending on system load and the variety and type of software programs running during the time period in question).

The following describes a different kind of clock, not related to time day but may be useful.

More reading:

This guide is meant as a basic explanation behind clock cycles at the very minimalist core of any digital device. It is by no means a comprehensive guide, but hopefully more of an introduction to people who are truly puzzled by the operation of computers.

The world of computers is binary. No matter how sophisticated the chip or architecture, digital components rely on 1’s and 0’s, on’s and off’s. But if a computer is simply a series of switches, how can it possibly perform the daily tasks we take for granted? It deals with the complex and varied implementation of an on-off switch, the transistor.

You can break down a computer chip much like a molecule. A molecule is made up of atoms, atoms of electrons, and so on down the line. A chip is made up of logical function units, which are made up of simple gates, which are made up, at the most basic level, of transistors.

In a perfect world, switches (like transistors) would operate in zero time. In other words, they would go directly from 0 to 1 or 1 to 0 instantaneously. With current technology, this is impossible, and it creates a problem when building complex digital systems. Depending on the complexity of a logical function, the number of transistors varies. This brings about the problem of the integration of many logic functions operating side by side.

Let’s take an example of adding two numbers, then storing the result into memory. An addition function would take many more transistors than a simple storage function. Since there are more transistors in the add function, it takes longer for the signal to travel through the adder than it does to travel through the storage logic. This causes instability in the system. Since the storage function will finish before the adder does, it may store a value that’s incorrect.

Think of two people walking. You put one person on a 1km straight path, and another on a 2km squiggly path and tell them to cross the finish line at the same time. It takes much longer for the second person to walk their path, so clearly the first person must wait to cross the line. This is where the idea of clocking comes in.

Digital systems use a clock as a “stop and wait” mechanism to keep all the different functions within a chip working on the same page. The clock pulse must be long enough to allow all operations to reach a stable state. This way the operations “cross the finish line at the same time". Now it's not that the clock makes things "wait", it's that the chips and funtions only operate during certain phases of the clock pulse as follows. For the most part they operate during:

  • rising edge (the instant when clock goes 0 to 1)
  • falling edge (1 to 0)
  • Hi true: operates as long as clock is 1
  • Low true: operates as long as clock is 0

Overclocking exploits this stability. As you increase the clocks, you’re decreasing the wait time available for functions to stabilize. If you use the example with the adder and storage and you increase the clock too much, you end up storing the data half way through the addition process (much like if there were no clock at all), so it could be totally incorrect. This causes the instability that is inherent with excessive overclocking.

From the outside, the function of a digital device is perplexing (multiplexing for those of you who know digital systems :-P). However, when you break it down to the very core of what’s happening, with 1’s and 0’s, it’s not entirely difficult to conceive. I hope this has helped someone to get a basic idea of what goes on in a computer, cell phone, camera, or any number of devices on the market today.

2
  • 6
    Interesting: On Gnu/Linux the system time is saved to the hardware clock at shutdown, because the hardware clock is LESS accurate than the system clock. So the hardware clock is only used when the system is off (and booting). For the case you gave, it could be fixed by rereading the hardware clock after re-enabling interrupts. Sep 12, 2012 at 9:14
  • 2
    Everything you added from More Reading is completely off topic. It is about a different type of clock. This type of clock has nothing to do with time. Sep 14, 2012 at 8:05
4
  • So you never have to set it.
  • So all nodes on a network are the same, to high accuracy. Some application need this e.g. File dates on shared file systems, if you are trying to workout what order things happened in.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .