system
Given the following post, respond as if you're commenting on Reddit:
human
Eli5: How does a computer know how long 1 sec is?

Do they perform a series of calculations that take exactly 1s? Or am i looking at it completely wrong?
gpt
Computer Engineer here,

Timekeeping on computers (indeed, most electronic devices) is performed using two methods.

1.) A small quartz crystal that, when energised, oscillates at exactly 32,768 hz, is fed through an amplifier and bistable oscillating circuit. This assembly is often embedded within a real-time-clock circuit, which in some products can track the date and time down to the millisecond. 32,768 is exactly 2^15 which is extremely easy to count in logic. One second elapses every 32,768 oscillations.

Crystals that oscillate at other frequencies, such as 50Mhz, and 100Mhz are available as well. As long as the oscillating frequency is known and oscillation is reliable, a counting circuit can be constructed around it.

2.) Most operating systems include support for the Network Time Protocol. There are a large number of NTP servers on the internet, computers simply query these to periodically update their system clocks in the event that the RTC wanders a bit; timezone and DST can also be updated if sufficient information is known.