poll的功能:
可以监视多个文件描述符,一旦某个文件描述符就绪(一般是读就绪或者写就绪),就能够通知应用程序进行相应的读写操作。
poll核心代码:
for (;;) {
struct poll_list *walk;
for (walk = list; walk != NULL; walk = walk->next) {
struct pollfd * pfd, * pfd_end;
pfd = walk->entries;
pfd_end = pfd + walk->len;
for (; pfd != pfd_end; pfd++) {
/** Fish for events. If we found one, record it and kill poll_table->_qproc,so we don't needlessly register any other waiters after this. They'll get immediately deregistered when we break out and return.*/
if (do_pollfd(pfd, pt)) {
count++;
pt->_qproc = NULL;
}