HACKER Q&A
📣 andrewstuart

Is a 1Mhz CPU precisely 1Mhz? How are clock crystals so accurate?


When programming something timing dependent it is often necessary to very precisely time things.

So I'm wondering if the system clock really is precisely the megahertz advertised?

And if so, how are crystals made so precise?


  👤 retrac Accepted Answer ✓
Generally accurate to dozens or hundreds of parts per million. A few seconds gain or lost per month. Piezoelectric crystals work on much the same principle as pendulums and tuning forks. They are precise shape and size, and they will oscillate very, very accurately. They actually look like miniature tuning forks. As to how they're made, the crystal is cut with a laser until it matches a reference source.

https://en.wikipedia.org/wiki/Quartz_clock


👤 mikewarot
Here's a movie about how crystals were made in the days before automation.

https://www.youtube.com/watch?v=wHenisSTUQY

Modern processes likely still use lapping to get the right thickness and hence frequency.


👤 mikewarot
The clock chips on most modern computers can be expected to be within 10 parts per million, so you might gain or lose a second or two per day. If the computer is synchronized to an NTP server, your long term accuracy and precision should be far better.

You should be made aware of the many, many falsehoods programmers believe about time - https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b...