π§ What is a CPU-bound process?
A CPU-bound process is one that spends most of its time using the CPU for computations, logic, or data processing, and rarely waits for I/O.
π Characteristics:
| Trait | CPU-Bound Process |
|---|---|
| π’ Workload | Heavy calculations (math, logic, compression) |
| β±οΈ CPU Usage | Very high |
| π³οΈ I/O Wait Time | Very low |
| π Performance Bottleneck | CPU becomes the limit |
| π§ Example | Video encoding, matrix multiplication, ML training |
π§ What is an I/O-bound process?
An I/O-bound process spends most of its time waiting for I/O operations (disk, network, input), and does very little computation.
π Characteristics:
| Trait | I/O-Bound Process |
|---|---|
| π€ Workload | Reading/writing files, databases, network |
| β±οΈ CPU Usage | Low |
| π³οΈ I/O Wait Time | High |
| π§± Performance Bottleneck | I/O devices (disk, network, etc.) |
| π§ Example | File downloader, web server, DB query engine |
π Timeline Illustration (Simplified)
CPU-bound process:
[ CPU ]ββ[ CPU ]ββ[ CPU ]ββ[ CPU ]ββ[ Done ]
I/O-bound process:
[ CPU ]ββ[ I/O wait ]ββ[ CPU ]ββ[ I/O wait ]ββ[ Done ]
π§ Why Does the OS Care?
The OS wants to keep both:
-
CPU busy (maximize utilization)
-
I/O devices active
To do that, the long-term scheduler tries to maintain a good mix of both process types:
-
Too many CPU-bound β long wait times in Ready Queue
-
Too many I/O-bound β CPU sits idle
π― Scheduler Behavior
| Scheduler Type | Works Best For |
|---|---|
| β±οΈ Round Robin | I/O-bound processes (responsive) |
| π§ Shortest Job First | CPU-bound processes (minimizes turnaround time) |
| πͺ Priority Scheduling | Mix of both (based on importance) |
βοΈ Real-Life Analogy
CPU-bound = a math nerd who keeps solving problems non-stop
I/O-bound = someone always waiting for someone to reply to their emails
π§ Interview-Ready Summary:
A CPU-bound process spends most of its time performing computations and needs more CPU time, while an I/O-bound process frequently waits on slow input/output operations and uses the CPU briefly.
A balanced OS keeps both types active to ensure maximum CPU and I/O utilization.