How does a program know actually what a second is?

615 views

So if a program needs to wait 10 seconds for something, how it is actually calculating it if the processors speed continously changes? (And i’m talking about offline programs that does not use NTP)

In: 361

20 Answers

Anonymous 0 Comments

There is a chip inside that has a crystal that pulses a certain number of times per second, usually in the millions or billions. That pulsing is connected to an interrupt, which is connected to a counter. When the computer turns on, the crystal starts counting, and it knows how many counts equals 1 second.

In order to store time between power turning on and off, the memory of what time it is needs to be saved. Most computers (motherboards) have a small battery that keeps a circuit on even when the computer is off to keep time.

If there is no saved time, the device can connect to the internet (or another device) and ask “what time is it?” And then keep count from there.

You are viewing 1 out of 20 answers, click here to view all answers.