Systems & 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.

RunWait for I/ORun

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.

RunRequest I/OReturns immediatelyRun

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 R1Wait R1End R1Start R4Wait R4End R4
Thread 2
Start R2Wait R2End R2
Thread 3
Start R3Wait R3End 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 R1FreeStart R4FreeHandle R1FreeHandle R4
Thread 2
Start R2Free for other workHandle R2
Thread 3
Start R3Free for other workHandle R3
OR
Single thread
Start R1Start R2Start R3Start R4FreeHandle R1Handle R2Handle R3Handle R4
Start / CPU workThread blocked by I/OFree for other workHandle completion

Conceptual model for learning · Not a performance benchmark

Detailed simulator

Workload settings

Tune the workload, then run both models together.

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