Inside the machine: CPU, memory and storage

Computer Science · Key Stage 3 · The School

A processor does something very simple, very fast. It FETCHES an instruction from memory. It DECODES it, working out which operation is being asked for. Then it EXECUTES it, and then it repeats. Everything a computer appears to do is that one cycle, running several billion times a second across several cores. A modern CPU is not cleverer than an old one in kind. It is faster, it runs more cycles at the same time, and it guesses ahead about which instruction will be needed next.

RAM is the working surface: fast, and reachable directly by the processor. It is also VOLATILE, which means its contents vanish the moment power is lost. Storage is different. An SSD or a hard disk is slower and much larger, and it is NON-VOLATILE, so it survives being switched off. This distinction is why unsaved work disappears in a power cut. The document existed in RAM and had never been written to storage, so there was nothing on the disk to recover.

Memory is arranged in layers because speed, size and cost pull against each other. Registers inside the CPU hold a handful of values and are effectively instant. Cache holds a few megabytes and takes a few cycles. RAM holds gigabytes and takes hundreds of cycles. An SSD holds terabytes and takes hundreds of thousands. Each layer down is roughly a hundred times slower and a hundred times cheaper per byte, so a machine keeps what it needs now at the top and everything else below.

A machine feels slow, so somebody fits more RAM, and nothing improves. Work out where the bottleneck actually was. If the old machine was full and constantly moving data between RAM and disk — swapping — then more RAM removes thousands of slow disk trips and the difference is dramatic. If it was never full, the extra RAM sits empty and the queue is somewhere else: a processor already at 100%, or a disk being read non-stop. The general rule is that adding capacity to a part that was not the constraint changes nothing, and the only way to know which part was the constraint is to measure it before you buy anything.

The School — all subjects · Knowledge map