Epoll VS select

I read a couple of online books to get an idea of ​​the differences between epoll and select, but they only covered these concepts a bit. I would appreciate it if you guys can provide me the key differences in the details.

Thanks in advance

+7
source share
2 answers

select is the standard Unix tool for performing asynchronous I / O. Its programming interface is fancy, and its implementation on most Unixs is mediocre at best. It also imposes a limit on the maximum number of descriptors that a process can observe, which is inconvenient in the application. In terms of efficiency, select performance usually degrades linearly with the number of descriptors.

epoll is a huge improvement over select in terms of programming interface and performance, but it has been provided only on Linux since version 2.6. Other Unixes also have their own specialized challenges.

+14
source

select always delivery descriptors to the kernel when select() called.
But epoll pass the descriptor once when calling epoll_ctl() and get events by calling epoll_wait() .

And loop 0 to max_descriptor for checking events when using select .
But the event loop had handles for checking events when using epoll .

This makes a difference in performance.

And select has a limit on the maximum number of descriptors, because it uses a bit array.
But epoll no limit, because it uses a structural array.

And select exists on most platforms (windows, linux, unix, bsd)
But epoll exists only on linux.
Of course, there are replacements for epoll on other platforms (IOCP on windows, kqueue on bsd, etc.)

+1
source

All Articles