Linux OS Internals (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is the difference between Blocking, Non-Blocking, and I/O Multiplexing?
senior LevelSystem Design
In Simple Words:
- Blocking I/O: Thread calls
read()and halts completely until data arrives. Requires 1 thread per connection (unscalable for 100,000 connections). - Non-Blocking I/O: Calls return immediately with
EAGAIN/EWOULDBLOCKif no data is ready. Requires busy polling (wastes CPU). - I/O Multiplexing (
epoll): A single thread registers 10,000 sockets with the kernel. The kernel wakes the thread only when one or more sockets are ready to read or write!