Appearance
13. Multithreading vs Multitasking vs Multiprogramming
1. Multiprogramming (1960s) — problem: CPU sat idle 80%+ of the time waiting on I/O. Fix: load several programs in RAM; switch when one blocks on I/O. Goal: maximize CPU utilization. No time slicing, no user interaction (batch).
2. Multitasking (1970s–80s) — problem: a CPU-bound job could hog the CPU forever under multiprogramming. Fix: a hardware timer forces a switch every quantum, regardless. Goal: responsiveness + fairness. Preemptive.
3. Multithreading (1990s–present) — problem: switching between heavy processes (full TLB flush) is expensive. Fix: multiple threads within one process, sharing memory, cheap to switch. Goal: concurrency + efficiency within a program.
| Aspect Multiprogramming Multitasking Multithreading | |||
|---|---|---|---|
| Unit | Program | Process | Thread |
| Switch trigger | I/O only | Timer + I/O | Timer + I/O + yield |
| Memory | Separate | Separate | Shared |
| Goal | CPU utilization | Responsiveness | Concurrency + efficiency |
| Context switch cost | High | High | Low |
| Era | 1960s | 1970s–80s | 1990s–now |
Modern OSes run all three at once: multiple processes in RAM (multiprogramming), timer-preempted for fairness (multitasking), each running several threads (multithreading) — e.g., Chrome uses separate processes per tab and multiple threads within each tab.