eli5: At the most basic level, how is a computer programmed to know how long a unit of time is?

84 views
0

eli5: At the most basic level, how is a computer programmed to know how long a unit of time is?

In: 2404

The clock circuitry counts the number of pulses generated by the oscillator over a given period of time, such as a second, and uses this count to calculate the passage of time. This counting process can be repeated for longer periods of time, such as minutes, hours, and days, to accurately measure the duration of time.

Computers can be programmed to know how long units of time are *in relation to other units of time*, like knowing that 60 seconds is 1 minute. But programming itself isn’t going to make them know how quickly time is passing.

Instead computers have various timing signals in order to operate. These are physical chips which exist just to create a regular signal, usually by a resonating quartz crystal.

Same way that a quartz watch does, usually – using an oscilator crystal with a known frequency. After that it’s all about counting.

There are certain crystals that vibrate when we apply electricity to them. We can exploit that vibration to make a device that opens and closes an electrical switch as it vibrates. That sends a “pulse” of electricity and we call this a “clock”.

The neat thing about these crystals is they vibrate at pretty much exactly the same frequency no matter what. So if we build a circuit that counts how many “pulses” have been sent, we know when it reaches a certain number 1 second has passed. We can use math to figure out smaller units of time.

The CPU in a computer already has to have a “clock” line. That periodic on and off pulsing is what tells it to perform its next instruction, it’s kind of like turning the crank on a jack in the box. So it can count these “cycles” to have an idea of the passage of time.

Imagine you are listening to the sound of a continuously bouncing football kept inside a small transparent box. Every time it bounces, you hear the sound non-stop.

Inside a computer, there is a tiny chip or material called a quartz crystal, which is made of silicon dioxide (SiO2), the same material that makes up sand and most rocks. Quartz crystals are piezoelectric, meaning that they generate an electric charge at precise and consistent intervals when subjected to an electric voltage.

Just like listening to the continuous bouncing of a football, in computers, there is a chip that senses the generated electric charge by this crystal. It sends this electric charge (signal) to all other chips that require this continuous signal to alter their own chip structure, which at a higher level is what we perceive as computation, processing, and programming.