当前位置:网站首页>Differences between select, poll and epoll in i/o multiplexing

Differences between select, poll and epoll in i/o multiplexing

2022-07-06 14:52:00 What should I do if I can't afford my beloved cat

I/O Multiplexing select、poll and epoll difference

  1. select: Through it , We can send the array of file descriptors to the operating system , Let the operating system traverse , Wait until the data arrives , Tell us which file descriptor can be read and written . The operating system kernel does traversal , There is no switching overhead from user mode to kernel mode
  2. poll: It and select The main difference is , Removed select Can only monitor 1024 Limit of file descriptors . because select Descriptor types use arrays , The default size is 1024;poll The descriptor type of is linked list .
  3. epoll: It's solved select Three shortcomings of , The kernel holds a set of file descriptors , You can register new descriptors with the kernel , Or change the state of descriptors in the descriptor set ; The kernel no longer finds ready file descriptors by polling , It's through asynchrony IO Events awaken ; The kernel will only have IO The file descriptor of the event is returned to the user , Users don't have to traverse the entire set of file descriptors .

select Three deficiencies :

  1. Copying arrays to the kernel will consume resources
  2. select The kernel is still traversing to check the ready state of the file descriptor , It's a synchronous process , It's just that there's no system call context switching overhead .
  3. select Returns the number of readable file descriptors , It's up to the user to traverse which one is readable .
原网站

版权声明
本文为[What should I do if I can't afford my beloved cat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131338245754.html