The processor, memory and disk
Lesson 2 of 4
2The processor, memory and disk
In the last lesson everything became numbers. Now we ask: who computes with those numbers, where do they live, and where are they kept?
Map of this part
The concepts in order, click any one to jump to it:
Two ways into the same idea
Think of a kitchen: the cook is the processor, fast but holding nothing for long. The counter is memory: whatever is being worked on sits there, and it is wiped when the kitchen closes. The fridge is the disk: slower to reach, but what is inside stays until morning.
The CPU runs instructions on very fast internal registers. RAM is volatile with access times in nanoseconds. An SSD or HDD is persistent and hundreds to thousands of times slower. That is why the system loads a program from disk into memory before running it, and why unsaved work is lost in a power cut.
Before You Start
💡The bits lesson
You know everything in a computer is bits, and a byte is eight of them.
🍳A kitchen picture
We borrow a cook, a worktop and a pantry; that is all the imagination you need.
The Core Idea
1The processor: computes, does not remember
The processor is a very fast cook with almost no memory. It takes one instruction, carries it out, and asks for the next. Billions of times a second.
Follow the picture: the instruction comes from memory, runs inside the processor, and the result goes back to memory. This three-step loop is everything any computer does.
The instructions themselves are very simple: add two numbers, move a number, compare, jump to another instruction. All the complexity comes from stacking millions of these simple steps.
2Memory: fast and forgetful
Memory, called RAM, is the worktop in front of the cook. Whatever the processor is working on right now is there, reachable in a billionth of a second.
But it needs electricity to hold its contents. Cut the power and everything is gone. That is why your writing is lost if you did not save before switching off.
Look at the speed ladder: registers inside the processor are a hundred times faster than memory, and the disk is a hundred thousand times slower than memory. Most of computer engineering is managing that gap.
3The disk: slow and never forgets
The disk is the pantry: it keeps everything without power, but reaching it is slow. A file sleeps there until you open it, when it is copied into memory for the processor to work on.
"Save" literally means: copy what is on the worktop into the pantry. "Open" is the reverse. And "the machine is slow" usually means the worktop filled up and the pantry is being used in its place.
A modern disk (SSD) has no moving parts and is tens of times faster than the old kind, but it is still far slower than memory, and that order will not change.
How It Works, Step by Step: What happens when you open a photo
You click the file, and the program asks the system to read it from the disk.
The photo's bits are copied from disk into memory. This is the slowest step, which is why large photos appear with a delay.
The processor reads the numbers from memory and computes the colour of every dot on screen.
The colours are sent to the screen. Closed the photo? It is wiped from memory while the file stays on disk as it was.
Try it without code
Myth vs Reality
| Myth | Reality |
|---|---|
| A faster processor always means a faster machine. | With little memory the processor spends most of its time waiting on the disk. Speed is the speed of the whole loop, not one part. |
| Memory and disk are two names for the same thing. | Memory is a fast worktop that forgets; the disk is a slow pantry that remembers. Mixing them up causes most confusion about "space". |
| A computer does many things at the same instant. | A processor runs one instruction at a time per core, but so fast that taking turns looks simultaneous. The next lesson shows how. |
Try it yourself
You wrote a long text and the power failed before you saved. Where was the text?
What you type lives in memory until you save it, and memory needs power to hold its contents. Saving is the copy to disk, which never happened.
Quick review cards
Check Your Understanding
Why not build a computer entirely from fast memory and drop the disk?
Fast memory is expensive and needs constant power. We need a cheap, large place that keeps data with no current.
Which improves opening programs more: a faster disk or a faster processor?
Usually the faster disk, because opening is a copy from disk to memory, and the processor waits during it.
What is the slowest step in the fetch-execute loop when the instruction is in memory?
The fetch from memory itself; a processor is a hundred times faster than its memory, which is why caches sit between them.
Resources for this lesson
Grouped by type. Start with the official docs for precision, or an article or video for the explanation.
Done with this lesson?
Sign in to save your progress.