Epoll

1

** **** is a Linux kernel system call for a scalable I/O event notification mechanism, first introduced in version 2.5.45 of the Linux **kernel. Its function is to monitor multiple file descriptors to see whether I/O is possible on any of them. It is meant to replace the older POSIX and system calls, to achieve better performance in more demanding applications, where the number of watched file descriptors is large (unlike the older system calls, which operate in O(n) time, operates in O(1) time). is similar to FreeBSD's, in that it consists of a set of user-space functions, each taking a file descriptor argument denoting the configurable kernel object, against which they cooperatively operate. uses a red–black tree (RB-tree) data structure to keep track of all file descriptors that are currently being monitored.

API

Creates an object and returns its file descriptor. The parameter allows epoll behavior to be modified. It has only one valid value,. is an older variant of and is deprecated as of Linux kernel version 2.6.27 and glibc version 2.9. Controls (configures) which file descriptors are watched by this object, and for which events. can be ADD, MODIFY or DELETE. Waits for any of the events registered for with, until at least one occurs or the timeout elapses. Returns the occurred events in, up to at once. is the maximum number of /file descriptors to be monitored. In most case, is set to the value of the size of argument ( array).

Triggering modes

provides both edge-triggered and level-triggered modes. In edge-triggered mode, a call to will return only when a new event is enqueued with the object, while in level-triggered mode, will return as long as the condition holds. For instance, if a pipe registered with has received data, a call to will return, signaling the presence of data to be read. Suppose, the reader only consumed part of data from the buffer. In level-triggered mode, further calls to will return immediately, as long as the pipe's buffer contains data to be read. In edge-triggered mode, however, will return only once new data is written to the pipe.

Bugs

Bryan Cantrill pointed out that had mistakes that could have been avoided, had it learned from its predecessors: input/output completion ports, event ports (Solaris) and kqueue. However, a large part of his criticism was addressed by 's and options. was added in version 2.6.2 of the Linux kernel mainline, released in February 2004. was added in version 4.5, released in March 2016.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original