Computer Systems and OS

Blocking vs Non-Blocking I/O Simulator

Compare thread pools and event loops under the same workload, then inspect queues, I/O activity, and completion time.

The difference in one glance

Start with what happens while an I/O operation is unfinished.

Blocking I/O

The thread stops and waits until the I/O finishes.

Run → Wait for I/O → Run

More waiting requests usually require more threads or remain in a queue.

Non-Blocking I/O

The event loop handles other requests while I/O is pending.

Run → Request I/O → Returns immediately → Run

One event loop can coordinate many pending requests without waiting on each one.

Four requests, two execution models

Follow the same four I/O requests from left to right.

Blocking 3 worker threads

“A worker cannot start another request while it is waiting for I/O.”

Thread 1
Start R1 Wait R1 End R1 Start R4 Wait R4 End R4
Thread 2
Start R2 Wait R2 End R2
Thread 3
Start R3 Wait R3 End R3

Non-Blocking with I/O Multiplexing 3 worker threads or 1 event-loop thread

“Workers are free for other work instead of being blocked by I/O.”

I/O still takes time, but the worker thread is not blocked while waiting.

Thread 1
Start R1 Free Start R4 Free Handle R1 Free Handle R4
Thread 2
Start R2 Free for other work Handle R2
Thread 3
Start R3 Free for other work Handle R3
OR
Single thread
Start R1 Start R2 Start R3 Start R4 Free Handle R1 Handle R2 Handle R3 Handle R4
Start / CPU work Thread blocked by I/O Free for other work Handle completion

Conceptual model for learning · Not a performance benchmark

Detailed simulator

Workload settings

Tune the workload, then run both models together.

Each non-blocking worker owns an event loop; callbacks return to the worker that started the request. CPU phases run without interruption, and I/O waits can overlap.

Ready. Adjust the settings, then run both models.
01 Thread pool

Blocking I/O

A thread stays occupied while I/O is in progress.

Thread waits
ACTIVE 0
QUEUED 0
DONE 0
THREAD POOL 0.00 s

Waiting request queue

02 Worker pool

Non-Blocking with I/O Multiplexing

Workers return after starting I/O and can process other runnable work.

Control returns
WORKERS IDLE
I/O 0
DONE 0
WORKER THREADS + ASYNC I/O 0.00 s

I/O in progress

Ready / callback activity

State at 0.00 s
Use Previous and Next to inspect important events.