是epoll的线程安全的? [英] Is epoll thread-safe?

查看:678
本文介绍了是epoll的线程安全的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个功能在epoll的:

There are two functions in epoll:


  1. epoll_ctl

  2. epoll_wait

他们是否线程安全当我用同样的epoll_fd?

如果一个线程调用epoll_wait和其他人在同一时间打电话epoll_ctl会发生什么?

Are they thread-safe when I use the same epoll_fd?
What will happen if one thread calls epoll_wait and others call epoll_ctl at the same time?

推荐答案

这是线程安全的,但没有明确规定,很多文件 - 请参阅<一个href=\"http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-03/msg00084.html\">http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-03/msg00084.html

It is thread-safe, but there isn't much documentation that explicitly states that - see http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-03/msg00084.html

顺便说一句,你也可以有多个线程在等待一个epoll_fd,但在这种情况下,它可以得到一个有点棘手(例如,你可能想使用边沿触发(EPOLLET)或单稳模式(EPOLLONESHOT) - 见<一HREF =htt​​p://linux.die.net/man/2/epoll_ctl> http://linux.die.net/man/2/epoll_ctl )

BTW, you can also have multiple threads waiting on a single epoll_fd, but in that case it can get a bit tricky (i.e. you might want to use edge-triggered (EPOLLET) or oneshot mode (EPOLLONESHOT) - see http://linux.die.net/man/2/epoll_ctl)

这篇关于是epoll的线程安全的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆