How do computers know that a second has passed?

In addition to the other answers here, I would like to add one answer.Some CPUs, but especially all so-called x86 processors (i.e. those that are now in all PCs and MACs) have had a special register, commonly referred to as TSC, for over 25 years. TSC stands for Time Stamp Counter. This tab is read out with the instruction RDTSC (therefore most information can be found under RDTSC and not under TSC, the term RDTSC has simply established itself).

The special thing about this register is that the CPU in this register counts up by one step with each clock cycle.In the case of a CPU clocked with a gigahertz, one billion counting operations per second actually take place here.

This register is used to measure high-precision time resolutions.After all, with a two-gigahertz CPU, a time interval of one nanosecond can be precisely determined (in theory half a nanosecond, but practically not, because you have a corresponding error due to the integer rounding).

Although the time measurement is complicated by the fact that the clock frequency of CPUs is dynamic nowadays, you only have to put a little more effort into it.

The external timers, such as the clock quartz, produce a usable time value that is always accurate to seconds.RDTSC also provides a high-precision time value, which is used for time measurements of units below 100 microseconds. It sounds crazy, by the way, because you think, “Who has to measure exactly to 100 microseconds, that’s insanely short”, but 100 usec are an eternity in computers.

In fact, 100 usec is even a certain magic value because, according to POSIX real-time specifications, this time span is the amount of time an operating system must respond to an event at the latest to be called a real-time OS (real-time operating system) may be allowed to be used.There is indeed a norm, realtime means not just fast, but with absolute guarantee always and in every situation damn fast (100 usec). The term realtime is used very inflationarily nowadays, but if there are computer-controlled control systems, then realtime is only used in accordance with standards.

I remember a trade show (more than 20 years ago) when Microsoft introduced a new Windows CE and raved about the real-time capabilities.Of course, the competitors from the real-time OS sector had also sat in the press room. The whole thing has become a disaster for Microsoft, because the presentation was shredded by targeted requests from competitors in the air. Microsoft just didn’t know that there was a norm for real time, and they just thought, well then we call our new OS realtime.

Realtime doesn’t mean “really damn fast (almost always),” but the “almost always” you have to leave out.

By the way, neither Android nor iOS nor Windows, nor Linux are realtime, they are only damn fast with potent hardware (but not guaranteed).

For a CPU, a second is an eternity.

Leave a Reply