我正在玩 Linux 系统调用,我发现了 的某些方面epoll
,这对我来说并不清楚。说,我创建一个epoll
实例:
epollfd = epoll_create(50);
for
接下来,我在-loop中注册 50 个文件描述符:
for(i=0; i<50; i++){
// open file "file-i".txt
// construct epoll_event
// register new file descriptor with epoll_ctl(epollfd, EPOLL_CTL_ADD ...
现在我们有 50 个文件,准备好执行操作(读或写——没关系)。我们将 MAX_EVENTS 设置为 3:
#define MAX_EVENTS 3
...
struct epoll_event events[MAX_EVENTS]
...
epoll_wait(epollfd, events, MAX_EVENTS, -1)
所有这 50 个文件都准备好了,我们只要求了其中的 3 个。哪些文件将在events
数组中?
- [1,2,3] -- 前 3 个文件,按添加到 epoll 的顺序排列
- [48,49,50] -- 最后 3 个文件按添加到 epoll 的顺序排列
- [34, 7, 15] -- 随机 3 个文件
- 任何其他选项
谢谢你。