107 / 163 · C11 · 8 min
A Dialogue on Virtualization
A light professor-student conversation that reveals how an operating system turns one physical CPU into many virtual CPUs so every program believes it owns the processor exclusively.
In this lesson
What Virtualization Actually Does
An operating system abstracts scarce physical hardware into apparently abundant virtual resources. For the CPU this means every running program feels as if it possesses an entire processor, even when the machine contains only one. That illusion underpins modern multitasking.
Why Programs Do Not Notice Sharing
Most of the time a program is not executing; it is waiting for input, disk, or a lock. The operating system exploits those idle windows to hand the CPU to another program. When the original program resumes it still sees “its own” processor and therefore never discovers that the resource was being rotated.
Time Slices and Rapid Switching
A hardware timer interrupts the current program every few milliseconds. The operating system saves that program’s registers and memory map, then loads another program’s state. These tiny time slices make many programs appear to advance together even though only one is physically executing at any instant.
Isolation and Efficiency from Virtualization
Because each program lives inside its own virtual-CPU world, a crash or infinite loop in one program rarely destroys the others. At the same time idle CPU cycles are immediately reused, so overall hardware utilization is far higher than in early single-task systems.
Pitfalls
- Thinking virtualization requires several physical CPUs
- Forgetting that a waiting program cannot observe the CPU being taken away
- Imagining a virtual CPU as a zero-overhead perfect replica
Run an example
This chapter is taught from the official PDF; there is no extra runnable program on this page.
CHECK YOUR UNDERSTANDING
Close the answer. Explain it.
If the operating system made time slices very long (several seconds), would programs still feel they own the CPU exclusively? Why?
Show a reference answer
No. Long slices would produce noticeable stalls and latency, revealing that the program does not truly own the processor.
Check the sources
Drafts and official chapters change. The version mark is only the example’s minimum.