epoll¶
Purpose¶
epoll provides a scalable event notification mechanism for monitoring large numbers of file descriptors.
Unlike poll(), which scans every file descriptor on each call, epoll maintains an internal set of monitored file descriptors and only returns those that are ready.
Core Components¶
An epoll instance consists of two logical collections:
| Component | Purpose |
|---|---|
| Interest List | Stores monitored file descriptors |
| Ready List | Stores file descriptors that are currently ready |
Each monitored file descriptor is represented internally by an epitem.
Registration Flow¶
Event Detection¶
epoll does not determine device readiness itself.
Instead, it calls the driver's standard .poll() callback.
The same driver callback is shared by:
poll()select()epoll()
Trigger Modes¶
Level Trigger (LT)¶
Level Trigger reports an event whenever the device remains ready.
Typical behavior:
Edge Trigger (ET)¶
Edge Trigger reports only readiness transitions.
Typical behavior:
Applications normally continue reading until no more data is available.
Typical APIs¶
Common Pitfalls¶
Warning
The Ready List is not the source of truth. Device readiness is always determined by the driver's current state.
Warning
Device drivers do not implement epoll-specific callbacks. They only implement the standard .poll() callback.