18

I can't seem to get a straight answer as to what a CPU clock is.

I know there are quartz crystal clocks that work by the bending of quartz that happens as an electrical current is passed through it. Do modern CPUs also use a crystal with the same property?

Ryan Folks
  • 191
  • 1
  • 1
  • 5

4 Answers4

38

Modern clocks are originally generated by quartz crystal oscillators of about 20MHz or so, and then the frequency is multiplied by one or more phase-locked loops to generate the clock signals for different parts of the system. (such as 4GHz for a CPU core).

This is mostly a question of electronics design, though.

7

A CPU clock is a signal which is used for two related purposes:

  1. Devices that are synchronous to a common clock agree that they will only look at signals from other such devices within a very short window after the clock changes.

  2. Devices which are synchronous to a common clock agree that within that window they will never change any signals that are of interest to other such devices.

A very important feature of such systems is that there is never any ambiguity over which of two things happens first. Instead, either one will happen on an earlier clock than the other, or they will happen on the same clock in which cases they are unambiguously tied.

If computers would always process all operations in a fixed sequence that is decided in advance, it could have the circuitry that performs each operation wait until all preceding operations are done, without any need for a clock. Some parts of systems are sometimes designed that way, but in many cases some resources will be required to perform several operations, and it may be desirable to allocate the resource immediately to whichever operation is ready to use it first, and then have any later operation that needs the resource wait until the first operation is done with it. In systems that don't use clocks, however, this will create a problem.

If two operations that would need a resource become ready simultaneously, it is necessary that the circuits that would perform the operations both agree on which one should go first, before either proceeds. If each tasks thinks it should go first, the tasks will grab the resource simultaneously (oops). If each task thinks it should defer to the other, the tasks will deadlock waiting for each other to complete.

There are ways of resolving such situations in asynchronous systems by having both tasks recognize a window in which the other task might have beaten them, and will back off for an amount of time based upon how far they think were from the edge of that window, and then see if that results or one side or the other winning unambiguously (backing off again if it doesn't). Unfortunately, while the probability of a tie lasting for more than t microseconds would decrease exponentially with t, it's often difficult to parameterize how fast that will occur.

Having devices operate synchronously fixes this, since it makes it possible to design two circuits so that X will take a resource as soon as it becomes ready unless Y had been ready for it during the previous observation window, and Y will take the resource as soon as it's ready unless either X was ready for it in the previous window, or has become ready in the current window. While the likelihood that X and Y become ready "simultaneously" would be much greater than in the asynchronous system, such occurrences wouldn't cause problems.

While there are a variety of ways that a computer can generate the clock signal which is used to coordinate communication among the many components, an understanding of the purpose of the clock is far more important, especially from a computer-science perspective, than knowledge of the particular means used to generate it, and the principles involved are very similar to those involving long-range networking.

supercat
  • 1,281
  • 8
  • 11
6

This is a picture of a DIY quartz clock:

quartz clock

This is (part of) a picture of a mainboard:

mainboard

Note the component I have marked with an arrow. You can see they look identical.

Some caveats:

  • Quartz crystals come in different packages, I have chosen two examples that happen to use the exact same package.
  • They will have different frequencies: mainboards usually use 14.318 MHz (I think that's a relic of TV output in early PCs), quartz clocks usually use 32.768 kHz (this one uses 12 MHz probably because their microcontroller can't run on such a slow clock).
  • The CPU does not use the 14.318 MHz directly but it is multiplied by a PLL circuit, possibly in one of the black ICs on the right side of the image.
AndreKR
  • 161
  • 2
-1

I beleive modern cpus require a click source signal which is usually generated by a capacitor circuitry rather then a crystal. I Beleive crystals and other ics are used more for arm mcu. For CPU’s an llc circuit is used to deliver the clock source.