Course outline
- 01How a computer works
- 02How the Internet works
- 03Introducing the GPU
- 04Tensors and models
- 4.1What is a tensor?soon
- 4.2What is an AI model?soon
- 4.3Training vs inferencesoon
- 05Splitting work across GPUs
- 5.1Why split work across GPUs?soon
- 5.2Data parallelismsoon
- 5.3Tensor parallelismsoon
- 5.4Pipeline parallelismsoon
- 5.5Expert parallelismsoon
- 5.6Which to use whensoon
- 06Serving LLMs with vLLM
- 6.1What is LLM serving?soon
- 6.2Meet vLLMsoon
- 6.3Serving a model with vLLMsoon
Lesson 1.4
How the CPU and memory work together
What happens, step by step, when you open a program.
In one line
When you open a program, the operating system copies it from storage into RAM, and the CPU runs it from there, reading and writing RAM all the time.
Real-life analogy
A customer orders lasagne. Here is what happens in the kitchen:
- The order reaches the kitchen.
- The manager finds the lasagne recipe and the ingredients in the pantry.
- They are placed on the counter, next to the chef.
- The chef follows the recipe, picking things up from the counter and putting finished parts back.
- The plate goes out to the customer.
In a computer, the manager is the operating system, the pantry is storage, the counter is RAM, the chef is the CPU, and the plate is what you see on screen.
Where the comparison stops working: in a kitchen, the ingredients leave the pantry. In a computer the program is copied into RAM, so the original stays in storage. And a real chef holds an ingredient in their hand, while the CPU keeps only a tiny amount of data inside itself; almost everything it works on stays in RAM.
Diagram
Step by step
You already know the three main parts: the CPU, RAM and storage. But who tells them what to do, and in what order? Let’s follow one click.
Meet the operating system
The operating system (OS) is the main program that manages the whole computer. Windows, macOS, Linux, Android and iOS are all operating systems.
The OS decides which program gets which part of RAM, which core runs what, and what appears on the screen. Think of it as the restaurant manager.
Step 1: you click
You double-click the icon of a music app. Your mouse click is input. The OS notices it.
Step 2: the OS finds the program in storage
The app is stored as a file in storage. That file is mostly a long list of instructions for the CPU, plus things like pictures and sounds the app needs.
Step 3: the program is copied into RAM
The OS sets aside a space in RAM for the app and copies what it needs from storage into that space. A running program like this is called a process.
Why copy it at all? Because RAM is much faster than storage. If the CPU had to fetch every instruction from storage, it would spend most of its time waiting.
Step 4: the CPU runs the instructions from RAM
The OS tells the CPU where the program’s first instruction is. The CPU starts its cycle: fetch an instruction from RAM, decode it, execute it, store the result.
The CPU and RAM now talk constantly. The CPU reads instructions and data from RAM, and writes new results back into RAM, over and over, extremely quickly.
Step 5: you see the result
Some of those instructions say “draw the app’s window” or “play this sound”. That becomes output: the window appears and the music plays.
And when you close it?
When you close the app, the OS frees its space in RAM, ready for something else. The app’s file is still safe in storage for next time.
Key takeaways
- The operating system is the manager: it starts programs and shares out RAM and CPU time.
- Opening a program copies it from storage into RAM. A running program is called a process.
- The CPU fetches instructions from RAM and writes results back to RAM, over and over.
- Closing a program frees its RAM. The file stays in storage.
Recap: order in, manager fetches the recipe from the pantry, ingredients go on the counter, chef cooks, plate goes out. That is exactly what your computer does every time you open an app.
Now you understand how the CPU, RAM and storage work as a team. Next: what happens before any of this is possible, when you first press the power button.
Quick check
Pick an answer, then press Check answer. Nothing is recorded.
Sources
This lesson was checked against these pages.
- What Is RAM vs. Processor? · Intel
- What Is Computer and Laptop RAM and Why Does It Matter? · Intel
- About Processes and Threads · Microsoft Learn
- What is a Central Processing Unit? · Arm