You open a browser. One tab is playing a song, another is downloading a form, a third is waiting for an exam result page, and in the corner of the screen a clock keeps ticking. Your laptop has four cores, maybe eight. Yet everything seems to happen at the same moment, and nothing freezes. Even a nearly idle Linux test session, checked on 16 November 2026, was running 30 processes and 40 threads on 16 CPU cores (you can count your own with ps -e --no-headers | wc -l, ps -eL --no-headers | wc -l and nproc; the numbers drift from minute to minute). How can so few cores look after so many jobs?
That's what this chapter is about. The operating system doesn't run "programs". It runs processes. It keeps a small file about each one, it moves each one through a handful of states (running, waiting, ready and so on), and it hands the CPU from one process to the next so quickly that you never see the seams. Inside a process, the real workers are threads, and one process may have several of them.
By the end you'll be able to say exactly what separates a program from a process, draw the memory of a process and tell where each variable lives, and list what the OS records in a Process Control Block. You'll draw the five-state and seven-state diagrams with every arrow named, and explain why two arrows that look natural are missing. You'll describe a context switch step by step and count what it costs. You'll say what threads share and what they keep for themselves, compare user-level and kernel-level threads and the three ways of mapping them, draw a thread's life cycle, and explain thread pools and thread cancellation.
We go in seven parts, from the simple to the subtle: from program to process, the five states, the seven states and the question of memory, the context switch, threads, how threads are supported, and finally threads at work.