epoll需要注意的

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.

猜你喜欢

转载自blog.csdn.net/xiaocszn/article/details/89285212
今日推荐