What is the difference between a CPU Clock Rate and the Clock Cycle?

470 viewsOtherTechnology

I was told that the CPU Clock is like a doorbell that informs the CPU about an upcoming program instruction. Each time an instruction is finished by the CPU, the clock can be “rang” again.

I understand that the CPU needs to take some steps to process an instruction. When all of these steps are completed, is this known as one “CPU cycle” and the amount of cycles per second is the clock rate measured in hertz? So would a clock rate of 3 GHz actually mean that the CPU can perform 3 billion instructions per second?

I find the CPU cycles and the clock rate a little difficult to understand. Because I’ve assumed that one cycle equals one processed instruction so 1Hz = 1 instruction but I’ve also read online that one instruction doesn’t always take one cycle.

So what exactly is one CPU cycle then and how does this correspond to the clock rate?

In: Technology

6 Answers

Anonymous 0 Comments

You have a basic understanding of this, you are just missing a few holes. Firstly the CPU does not advance to the next cycle once it is finished with an instruction. The cycles are set by a clock that does not know anything about the instructions or data in the CPU. It just goes constantly at the same rate.

The clock signal is used to make sure all transistors do things at the same rate. Electricity takes time to go through wires and through transistors. So you need a way to say that one calculation is done and that you can now take your next input. This is what the clock cycles are for.

As you say each instructions have multiple steps to them, so called microinstructions. And the CPU does one microinstruction per cycle. If you look up in old processor manuals they list how many cycles each instruction takes. And this can vary depending on various conditions.

Things become more complex as you look at more modern processors. Each microinstruction only uses a few components of the CPU. If built correctly you might be able to start the next instruction before the previous one is done calculating as they can use different components within the same core. A very early example of this is that you can load the next instruction from memory while the current one is running, assuming it is done reading from memory. And speaking of memory you might start loading the data from memory needed by one instruction while the previous is still running, and then save the result of one instruction while the next is running. This way expensive memory operations might overlap with calculating data in the core so you can get twice the speed.

This was still early optimalization techniques we did in the 80s. Modern CPUs can run a handful of instructions in parallel on the same core. To speed things up it can even run instructions for two different threads. So when you ask how many clock cycles an instruction takes it can be complicated. It is easier to tell you how many clock cycles a block of code takes to execute.

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