Part 5 · 2 chapters · ~12 min
IO and Device Drivers
Device drivers, port and memory-mapped IO, polling, interrupts and DMA, interrupt handling and softirqs, block and character devices, the IO models (blocking, non-blocking, multiplexed, asynchronous), epoll, kqueue and io_uring, and batching to reduce boundary crossings.
11
Interrupts, DMA and drivers
Everything the Node course said about the event loop (epoll, kqueue, the threadpool for files) is this part seen from the application side.
HOW A DEVICE TALKS TO THE CPU
interrupts, DMA and drivers
swipe the figure sideways, or tap expand for full screen
1/4
drivers
A driver is kernel code that knows one device: how to configure it, submit work and handle completion. Most of the Linux source tree is drivers.
kernel code per device typemost of the kernel is drivers
12
IO models
| model | how | used by |
|---|---|---|
| blocking | read() sleeps until data arrives | thread-per-connection servers |
| non-blocking | read() returns EAGAIN if nothing is ready | building block for event loops |
| multiplexed readiness | select, poll, epoll (Linux), kqueue (BSD, macOS): wait on many fds at once | Nginx, Node, Redis, Go's netpoller |
| completion-based asynchronous | submit operations, collect completions (IOCP on Windows, io_uring on Linux) | newer databases and runtimes; works for files too |