Applications that use nonblocking I/O often use the poll, select, and epoll system
calls as well. poll, select, and epoll have essentially the same functionality .each allow
a process to determine whether it can read from or write to one or more open files
without blocking.
Support for any of these calls requires support from the device driver. This support
(for all three calls) is provided through the driver’s poll method. This method has the
following prototype:
unsigned int (*poll) (struct file *filp, poll_table *wait);
The driver method is called whenever the user-space program performs a poll, select,
or epoll system call involving a file descriptor associated with the driver. The device
method is in charge of these two steps:
1. Call poll_wait on one or more wait queues that could indicate a change in the
poll status. If no file descriptors are currently available for I/O, the kernel causes
the process to wait on the wait queues for all file descriptors passed to the sys-
tem call.
2. Return a bit mask describing the operations (if any) that could be immediately
performed without blocking.