【发布时间】:2013-06-16 23:10:34
【问题描述】:
我想知道 i/o 观察者 inotify 和 epoll 之间有什么区别?
通知
- inotify_init(void) 创建 inotify 实例以从中读取事件
- inotify_add_watch(int fd, const char * path, int mask) 在路径后面的文件节点周围返回一个 watch fd
- inotify_rm_watch(int fd, int wd) 停止监视 fd 上的事件
电子投票
- epoll_create(void) 创建 epoll 对象
- epoll_ctl(int epfd, int op, int fd, struct epoll_event * event) 设置要观看的事件
- epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); 阻塞直到事件发生
因此,文件监视似乎有不同的方法。 Inotify 尝试让用户决定何时收集事件,而 epoll 会阻塞直到发生某些事情。
这是正确的吗?还有什么区别?
【问题讨论】: