Blocking vs Non-Blocking & Asynchronous I/O
Explore the 5 I/O models: Synchronous Blocking, Synchronous Non-Blocking, I/O Multiplexing (select/poll/epoll), Signal-Driven I/O, and Asynchronous I/O (io_uring).
01.1. The 5 Classical I/O Models (W. Richard Stevens)
In UNIX networking, the journey of an incoming network packet or disk read involves two distinct phases:
- Phase 1: Waiting for Data to be Ready: The kernel waits for packets to arrive from the network card (NIC) or disk controller buffer into kernel space memory.
- Phase 2: Copying Data from Kernel to User Space: The kernel copies the buffered bytes from kernel memory into the application process's user-space buffer.
W. Richard Stevens identified the 5 fundamental I/O models based on how applications interact with these two phases:
- Synchronous Blocking I/O: The calling thread calls
read()and is placed in an uninterruptible sleep state by the OS scheduler until data arrives in kernel space AND is fully copied to user space. - Synchronous Non-Blocking I/O: The calling thread sets the socket flag to
O_NONBLOCK. If no data is available,read()immediately returnsEAGAINorEWOULDBLOCK. The thread must continuously poll the socket in a busy-wait CPU loop. - I/O Multiplexing (
select,poll,epoll,kqueue): The thread registers thousands of file descriptors with the kernel. The single thread blocks inepoll_wait(), and the kernel wakes it only when one or more sockets are ready. - Signal-Driven I/O (
SIGIO): The kernel delivers an asynchronous POSIX signal (SIGIO) when data is ready on a descriptor. - Asynchronous I/O (POSIX AIO, Linux
io_uring, Windows IOCP): The application submits an I/O request and continues immediately. The kernel handles both Phase 1 and Phase 2 in the background, notifying the application only after data has already been copied into the user-space buffer.
Synchronous Blocking I/O vs I/O Multiplexing (epoll) vs True Async (io_uring) ⏱️
Synchronous Blocking I/O vs I/O Multiplexing (epoll) vs True Async (io_uring) ⏱️
How modern operating systems evolved from thread-per-connection bottlenecks to event-driven I/O multiplexing and zero-syscall io_uring ring buffers.
Unlock Topic #22: Blocking vs Non-Blocking & Asynchronous I/O
You are viewing a preview. The full in-depth engineering deep dive, interactive simulators, architecture flowcharts, and self-assessment quizzes for this topic are available with Pro or Lifetime Access.
Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.
Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.
Staff-level multiple-choice quiz questions with instant feedback and answer explanations.
Firebase Google authentication automatically syncs your completed topics and quiz scores.
How clear and staff-actionable was this system breakdown?