Tech●●●●●Difficulty 4 of 5

What does a processor actually do billions of times every second?

A 4 GHz chip repeats the same three-step routine four billion times a second, and that routine is the whole secret of what a computer 'does'.

▶ Start the story

A processor doesn't think, exactly. It repeats one small routine, over and over, from the moment it boots until it shuts down: fetch an instruction, decode it, execute it. That three-step loop is called the instruction cycle, and it is, underneath everything, what a computer actually does.

Fetch means the processor looks at a register called the program counter, which holds the address of the next instruction, and pulls that instruction in from memory. Decode means the control unit figures out what the instruction is asking for and readies the right components, such as the arithmetic logic unit built from adders. Execute means those components actually carry it out: an addition happens, a value moves, a branch is taken. Only this last step is useful to you; the rest is overhead that makes it possible.

The instruction cycle
  1. Step 1: Fetch

    Get the next instruction from the address in the program counter

  2. Step 2: Decode

    The control unit works out what the instruction needs

  3. Step 3: Execute

    The ALU or another unit actually carries it out

  4. Step 4: Repeat

    The program counter moves on, and the cycle starts again

A clock drives the whole thing, ticking at a frequency measured in gigahertz. After each tick, the processor's internal signals need a moment to settle before the next tick arrives, or the result comes out wrong. In simple processors, each instruction's three steps run start to finish before the next instruction begins. Modern processors instead overlap them in a pipeline, starting the next instruction's fetch while the current one is still being decoded or executed, so an instruction can finish on almost every single clock tick instead of every three.

That overlap isn't free. If a program suddenly jumps somewhere else, like at an if statement, the pipeline may have to throw out instructions it already started on and begin again, a stall. Some processors run pipelines ten or even twenty stages deep to squeeze out more speed, accepting more of these stalls as the price. To avoid most of them, processors guess: a branch predictor bets on which way the jump will go and starts down that path early. Guess right and no time is lost. Guess wrong and the work is thrown away.

Quiz me

0/3

  1. 1.How can a pipelined processor finish about one instruction per clock tick, instead of one every three?
  2. 2.Why can't a CPU's clock simply be made to tick faster and faster?
  3. 3.What happens in a pipeline stall?

Recap

Fetch gets the instruction, decode figures out what it means, execute actually does it — only execute is useful to you, and pipelining overlaps these stages across instructions at the cost of occasional stalls.

Surprising fact · A 4 GHz processor runs this three-stage cycle roughly four billion times per second, and modern chips overlap many instructions at once in a pipeline to keep up that pace.

Sources (4)

No source, no claim. Every fact in this lesson (18 claims) cites at least one of these.

  1. [1]Instruction cycle · Wikipedia
  2. [2]Clock rate · Wikipedia
  3. [3]Instruction pipelining · Wikipedia
  4. [4]Dennard scaling · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗