标签:1.5 时间 ted monit 直接 http init number net
1.用户空间调用(参考 poll(2) - Linux man page)
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
it waits for one of a set of file descriptors to become ready to perform I/O.
The set of file descriptors to be monitored is specified in the fds argument, which is an array of structures of the following form:
struct pollfd { int fd; /* file descriptor */ short events; /* requested events */ short revents; /* returned events */ };
关于timeout参数的说明:
timeout>0,设置超时时间为timeout
timeout=0,直接返回
timeout<0,无限长超时时间
返回值说明:
On success, a positive number is returned; this is the number of structures which have nonzero revents fields (in other words, those descriptors with events or errors reported).
A value of 0 indicates that the call timed out and no file descriptors were ready. On error, -1 is returned, and errno is set appropriately.
2.内核调用
asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int 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) -->if (file->f_op && file->f_op->poll)
2.1
标签:1.5 时间 ted monit 直接 http init number net
原文地址:http://www.cnblogs.com/yangjiguang/p/7622780.html