是epoll的线程安全的?

编程入门 行业动态 更新时间:2024-10-24 18:17:27
本文介绍了是epoll的线程安全的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有两个功能在epoll的:

There are two functions in epoll:

  • epoll_ctl
  • 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?

    推荐答案

    这是线程安全的,但没有明确规定,很多文件 - 请参阅linux.derkeiler/Mailing-Lists/Kernel/2006-03/msg00084.html

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

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

    更多推荐

    是epoll的线程安全的?

    本文发布于:2023-11-12 04:36:02,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1580521.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:线程   epoll

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!