图文详解Linux EPOLL

SELECT/POLL存在的问题

Linux EPOLL是对select和poll的改进,因此在分析epoll之前需要对select/poll有一定的了解。

select存在的几个问题:

  1. 每次调用select,都需要把监控的fds集合从用户态拷贝到内核态,高并发场景下这样的拷贝会使得消耗的资源很大;
  2. 监听的端口数量有限;
  3. 有事件返回时,需要遍历fds集合,找到可读可写的事件;

poll对监听端口数量限制做了改进,但还是存在2个问题:

  1. 每次调用poll,都需要把监控的pollfds集合从用户态拷贝到内核态,高并发场景下这样的拷贝会使得消耗的资源很大;
  2. 有事件返回时,需要遍历pollfds集合,找到可读可写的事件;

什么是EPOLL

取维基百科上的一段话 (epollis a Linux kernelsystem call for a scalable I/O event notification mechanism, first introduced in version 2.5.44 of the Linux kernel.[1] Its function is to monitor multiple file descriptors to see whether I/O is possible on any of them. It is meant to replace the older POSIXselect(2)andpoll(2)system calls, to achieve better performance in more demanding applications, where the number of watched 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小虾米的Daddy

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值