Programming foundations

Stage 3 · Lesson 5 of 9

How a CPU runs a program

How computers run your code

A , the chip that runs your code, repeats one cycle billions of times a second. It fetches the next instruction from memory, decodes it (works out what it means), executes it, and moves on. Instructions are tiny steps: load a value into a , add two registers, compare, jump to another address.

Registers are a handful of very fast storage slots inside the CPU. Main memory is much slower, so a , a small store of recently used data, sits close by. Every line you write becomes many of these machine code instructions.

This explains practical things later. Walking an array in order is faster than jumping around memory. And a million iterations are nothing for a CPU, while a million network calls take a very long time.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Keep handy

  • Quick explanations of OS basics like processes and memory when a lecture skips a step

Also worth your time

  • Everything from a key press to a rendered page; read it after this stage

Mark this stage as not done?