Understanding of epoll, select, poll of

select: Polling + fd_set

1. The use of FD fd_set storage (fd_set implemented by the bitmap array)

2. Each call to select, from the set of fd need to copy the user mode to kernel mode, the greater the more the overhead fd

3. Each select call, you need to traverse passed in the kernel fd, large overhead (poll)

4.select supported by too few fd, 1024

5. Call select, returns an array containing the entire handle, you need to traverse the entire array to know what happened handle events (polling)

6.select trigger LT model is not efficient


poll: polling list +

1. The linked list stores fd, fd is not a limitation of quantity, but the other disadvantages remain above


epoll: red-black tree + + callback mechanism doubly linked list

1. red-black tree mount event, add the time of the incident by incident callback mechanism to doubly linked list

2. Check whether there is an event occurs, no polling, just double check the list to

3. ensure that each fd will only be copied once (when the event is added to the epoll, fd will be copied into the kernel, instead of copying when epoll_wait)

The upper limit for the number of 4.fd maximum number of files that can be opened

The doubly-linked list we generally called the ready event


// the first code, prepare yourself behind the realization of these three mechanisms



Guess you like

Origin www.cnblogs.com/yinbiao/p/10945624.html