Does epoll preserve the order in which fd's was registered?

前端 未结 1 1876
予麋鹿
予麋鹿 2021-01-18 05:39

I\'m playing around with Linux system call and I found some aspect of epoll, that is not clear to me. Say, I create a epoll instance:



        
1条回答
  •  遥遥无期
    2021-01-18 06:24

    Perusing through the source file for epoll, one sees that the ready events are maintained in a linked list. Events are removed from the head of the list and added to the end of the list.

    Based on that, the answer is that the descriptor order is based on the order in which they became ready.

    This behavior is now documented in the notes for epoll_wait:

    If more than maxevents file descriptors are ready when epoll_wait() is called, then successive epoll_wait() calls will round robin through the set of ready file descriptors. ...

    The documentation is thanks to @mtk .

    0 讨论(0)
提交回复
热议问题