Inside the CPU

IntermediateAbout 12 minNetworks & systems

The processor in your phone only knows how to do very simple things. It just does them billions of times a second.

The Brain That Follows a List

The CPU (central processing unit) is the part of a computer that runs programs. It doesn't understand apps or games. It understands tiny instructions like "load this number", "add these two" and "save the result". A program is a long list of them, stored in memory.

The CPU works through the list with the same three steps, over and over:

  1. Fetch — get the next instruction from memory.
  2. Decode — work out what the instruction means.
  3. Execute — do it.

The fetch–decode–execute cycle: the loop every program runs on, billions of times a second.

The CPU's Notepad

Inside the CPU are a few very fast storage spots called registers. The demo uses three:

  • Program counter — the address of the next instruction to fetch.
  • Instruction register — the instruction being worked on right now.
  • Accumulator — where the result of a calculation is kept.

Try it yourself

Memory

0Program counter
—Instruction
0Accumulator

Faster and Faster

A CPU's clock ticks billions of times a second — a 3 GHz processor ticks about three billion times. Each tick moves the work forward. Modern CPUs also have several cores, which are like several CPUs in one chip, each running its own fetch–decode–execute loop at the same time. That's the same idea as running tasks in parallel.

Memory vs Storage

RAM (memory)

Very fast. Holds the programs and data in use right now.

Forgets everything when the power goes off.

Storage (SSD or hard drive)

Slower, but much bigger and cheaper.

Keeps your files and apps when the power is off.

When you open an app, it's copied from storage into RAM so the CPU can fetch its instructions quickly.

Check your understanding

5 quick questions. Pick one answer for each — you'll see why straight away.

  1. What are the three steps the CPU repeats for every instruction?

  2. What does the program counter hold?

  3. A CPU is described as 3 GHz. Roughly what does that mean?

  4. Why does a computer need RAM as well as storage like an SSD?

  5. In the demo, what does STORE 7 do?