Inside the machine: CPU, memory and storage

Beginner6 min readPart 5 of 9

The processor, memory and storage each have a different job. See how they work together, using a kitchen as the picture.

If you opened up a laptop, you would see a few important parts. Each has its own job, and they work together like a team. The easiest way to remember them is to picture a kitchen.

The kitchen picture

Processorthe chefdoes the work,billions of stepsevery secondMemorythe countersmall and fast,cleared when thepower goes offStoragethe pantrybig and slower,keeps thingswith no powerCPURAMSSD or hard drivefast and small ←→ slow and big
The chef works on what is on the counter. When the counter is full, things go back to the pantry.

The processor is the chef

The processor, or CPU (central processing unit), is the part that does the work. It follows the instructions, one tiny step at a time, and does the sums.

How fast? Its speed is measured in gigahertz (GHz). A processor of 3 GHz "ticks" about 3 billion times every second, and each tick can carry out a step.

Many processors have several cores, which are like having several chefs, each working on a different job at the same time.

Memory is the counter

Memory, often called RAM, is where the computer keeps what it is working on right now. It is like the kitchen counter: it is small, but everything on it is within easy reach, so the chef can work quickly.

The catch: when the power goes off, the counter is wiped clean. Memory forgets everything.

Storage is the pantry

Storage (an SSD or a hard drive) is where files and programs are kept for the long term. It is like the pantry or the fridge: much bigger than the counter, but slower to fetch from. And it keeps everything even when the power is off.

When you open a game, the computer copies it from the pantry (storage) to the counter (memory). Then the chef (processor) can work on it quickly.

PartKitchenSpeedSizeKeeps data with no power?
Processor (CPU)ChefVery fastTinyNo
Memory (RAM)CounterFastMediumNo
Storage (SSD)PantrySlowerLargeYes

What happens when you run a program?

Inside, the processor repeats three steps, over and over, billions of times a second. It is called the fetch-decode-execute cycle:

  1. Fetch. Grab the next instruction from memory.
  2. Decode. Work out what the instruction is asking for.
  3. Execute. Do it, for example by adding two numbers, and then go back to step 1.

That is it. All the things a computer does are this tiny loop, repeated. The magic is in the speed and in the instructions.

Other parts

Why does a computer slow down?

When memory (the counter) gets full, the computer has to move things back and forth to storage (the pantry). That takes far longer. It is like a chef who keeps running to the pantry because the counter is full.

A tour of the numbers

A typical laptop might have a processor ticking at 3 billion times a second, 8 to 32 gigabytes of memory, and hundreds of gigabytes or a terabyte of storage.

Words to know

CPU
The central processing unit, the part that follows instructions and does the sums.
Core
One worker inside a processor. Many processors have several.
RAM
Memory that holds what the computer is working on now. It is cleared when the power goes off.
Storage
Where files and programs are kept for the long term, such as an SSD.
GPU
A chip with thousands of small cores, good at lots of simple jobs at once.
Operating system
The main program that manages the computer and everything running on it.

Check yourself

  1. In the kitchen picture, which part is the chef, the counter and the pantry?

    Show the answer

    The processor is the chef, memory is the counter, and storage is the pantry.

  2. Which keeps your files when the power is off: memory or storage?

    Show the answer

    Storage. Memory forgets everything when the power goes off.

  3. What are the three steps the processor repeats?

    Show the answer

    Fetch an instruction, decode it, and execute it.

  4. Why is a GPU useful for AI?

    Show the answer

    It has thousands of small cores that can do lots of simple calculations at the same time, which suits training AI.