poll vs epoll vs select

这篇文章整理的不错: http://blog.sina.com.cn/s/blog_8fa7dd41010153zx.html

另外,poll/select 都有对应的ppoll/pselect,存在的理由主要是,

The reason that pselect() is needed is that if one wants to wait for either a signal or for a file descriptor to become
ready, then an atomic test is needed to prevent race conditions. (Suppose the signal handler sets a global flag and
returns. Then a test of this global flag followed by a call of select() could hang indefinitely if the signal arrived
just after the test but just before the call. By contrast, pselect() allows one to first block signals, handle the sig-
nals that have come in, then call pselect() with the desired sigmask, avoiding the race.

posted on 2012-11-18 17:49  RaymondSQ  阅读(407)  评论(0编辑  收藏  举报