1. User space Invocation (ref. poll (2)-Linux man page)
int poll (struct POLLFD *fds, nfds_t nfds, int timeout);
It waits for one of a set of the file descriptors to become ready to perform I/O.
The set of file descriptors to be monitored are specified in the fds argument, which are an array of structures of The following form:
struct POLLFD { int FD; /* */short events; /* */short revents; /* */};
A description of the timeout parameter:
Timeout>0, set timeout time to timeout
Timeout=0, return directly
Timeout<0, unlimited long timeout time
Return Value Description:
On success, a positive number is returned; This is the number of structures which has nonzero revents fields (in other words, those descriptors with events or error S reported).
A value of 0 indicates the call timed out and no file descriptors were ready. On error, 1 are returned, and errno is set appropriately.
2. Kernel calls
long sys_poll (structint Nfds,long timeout_msecs) -->ret = Do_ Sys_poll (UFDs, Nfds, &timeout); --struct poll_wqueues table ; -->poll_initwait (&table); -->init_poll_funcptr (&pwq->pt, __pollwait); -->fdcount = Do_poll (Nfds, head, &table, timeout); --DO_POLLFD (PFD, PT )--andif (file->f_op && file->f_op->poll)
2.1
Linux poll mechanism