-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IO模型,同步异步,阻塞非阻塞, Select, Poll, Epoll #29
Comments
同步IO之 IO多路复用
2.同时每次调用select都需要在内核遍历传递进来的所有fd,这个开销在fd很多时也很大 3.select支持的文件描述符数量太小了,默认是1024
3.对于第三个缺点,epoll没有这个限制,它所支持的FD上限是最大可以打开文件的数目,这个数字一般远大于2048,举个例子,在1GB内存的机器上大约是10万左右,具体数目可以cat /proc/sys/fs/file-max察看,一般来说这个数目和系统内存关系很大。 总结: (2)select,poll每次调用都要把fd集合从用户态往内核态拷贝一次,并且要把current往设备等待队列中挂一次,而epoll只要一次拷贝,而且把current往等待队列上挂也只挂一次(在epoll_wait的开始,注意这里的等待队列并不是设备等待队列,只是一个epoll内部定义的等待队列)。这也能节省不少的开销。 |
几张图比较清楚说明关系
参考https://cloud.tencent.com/developer/article/1005481
一个关于epoll的总结挺好:
https://www.cnblogs.com/Anker/archive/2013/08/17/3263780.html
The text was updated successfully, but these errors were encountered: