http://man7.org/linux/man-pages/man7/epoll.7.html
FAQ
2. Can two epoll instances wait for the same file descriptor? If so, are events reported to both epoll file descriptors?
一个文件描述符能不能被两个epoll实例监测?
Yes, and events would be reported to both. However, careful programming may be needed to do this correctly.
可以,并且这两个epoll都会得到事件通知。
3. Is the epoll file descriptor itself poll/epoll/selectable?
Yes. If an epoll file descriptor has events waiting, then it will indicate as being readable.
If multiple threads (or processes, if child processes have inherited the epoll file descriptor across fork(2)) are blocked in epoll_wait(2) waiting on the same the same epoll file descriptor and a file descriptor in the interest list that is marked for edge- triggered (EPOLLET) notification becomes ready, just one of the threads (or processes) is awoken from epoll_wait(2). This provides a useful optimization for avoiding "thundering herd" wake-ups in some scenarios.
本文详细探讨了epoll的工作机制,解答了是否一个文件描述符能被多个epoll实例监测的问题,确认事件会报告给所有监测该文件描述符的epoll实例。同时,文章讨论了epoll文件描述符自身是否可被poll/epoll/select操作,指出当有等待事件时,epoll文件描述符将指示为可读状态。此外,针对多线程或多进程同时阻塞在epoll_wait上等待同一epoll文件描述符的情况,文章说明了仅有一个线程或进程会被唤醒,避免了雷鸣群唤醒问题,提供了优化方案。
3346

被折叠的 条评论
为什么被折叠?



