Which one would you like to use select, poll or epoll? and why??
Any how I have to use only that is supported by my system.
But if all are supported than rank will be epoll, poll and last select in ascending order.
Because there are lots of pros and cons for all three.
fds stands for file descriptors here.
1.
But in epoll, you just have to copy fds and events from user space to kernel space only ones before going into epoll_wait call. So it saves two things looping and coping to user space to kernel space in every next epool_wait call. So its a big advantage.
2.
But in epoll, after coming from epoll call, it gives you list of fds which have events. So you have to loop only those fds who have events but not all fds. So it saves much time.
3.
4.
But in case of poll and epoll, they are scalable.
5.
But in case of poll it is in revents of pollfd sturcture and in epoll it is in events of epoll_event structure. So you do not have to loop separately.
6.
<Sumit kakadiya>
Any how I have to use only that is supported by my system.
But if all are supported than rank will be epoll, poll and last select in ascending order.
Because there are lots of pros and cons for all three.
fds stands for file descriptors here.
1.
In select and poll before going to call of select and poll, you have to copy fds and their events from user space to kernel space every time. And to copy or register this events, you have to loop the fds every time also. So its a big overhead.
But in epoll, you just have to copy fds and events from user space to kernel space only ones before going into epoll_wait call. So it saves two things looping and coping to user space to kernel space in every next epool_wait call. So its a big advantage.
2.
In select and poll , after coming from select and poll, you again have to loop all fds and have to check their events. So even if fd's events is not set, you also have to check it. So again its a big over head.
But in epoll, after coming from epoll call, it gives you list of fds which have events. So you have to loop only those fds who have events but not all fds. So it saves much time.
3.
epoll works with signalfd, timerfd, eventfd.
4.
select is not scalable because the fd_set size (probably your system may have limit to 1024) is limited in our system.
But in case of poll and epoll, they are scalable.
5.
In select you have to give read , write and error descriptors to separate fd_set. So You have to loop all three to check for events.
But in case of poll it is in revents of pollfd sturcture and in epoll it is in events of epoll_event structure. So you do not have to loop separately.
6.
Biggest disadvantage of epoll is that it is not supported by all system and it is not that much portable like select and poll. But if my system supports epoll, I will go for it.
<Sumit kakadiya>
No comments:
Post a Comment