Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

epoll

From Wikipedia, the free encyclopedia
Linux-specific system call for a scalable I/O event notification mechanism

epoll is aLinux kernelsystem call for a scalable I/O event notification mechanism, first introduced in version 2.5.45 of theLinux kernel.[1] 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 olderPOSIXselect(2) andpoll(2)system calls, to achieve better performance in more demanding applications, where the number of watchedfile descriptors is large (unlike the older system calls, which operate inO(n) time,epoll operates inO(1) time).[2]

epoll is similar toFreeBSD'skqueue, in that it consists of a set ofuser-space functions, each taking afile descriptor argument denoting the configurable kernel object, against which they cooperatively operate.epoll uses ared–black tree (RB-tree) data structure to keep track of all file descriptors that are currently being monitored.[3]

API

[edit]
intepoll_create1(intflags);

Creates anepoll object and returns its file descriptor. Theflags parameter allows epoll behavior to be modified. It has only one valid value,EPOLL_CLOEXEC.epoll_create() is an older variant ofepoll_create1() and is deprecated as of Linux kernel version 2.6.27 and glibc version 2.9.[4]

intepoll_ctl(intepfd,intop,intfd,structepoll_event*event);

Controls (configures) which file descriptors are watched by this object, and for which events.op can be ADD, MODIFY or DELETE.

intepoll_wait(intepfd,structepoll_event*events,intmaxevents,inttimeout);

Waits for any of the events registered for withepoll_ctl, until at least one occurs or the timeout elapses. Returns the occurred events inevents, up tomaxevents at once.maxevents is the maximum number ofepoll_event/file descriptors to be monitored.[5][6] In most case,maxevents is set to the value of the size of*events argument (struct epoll_event *events array).

Triggering modes

[edit]

epoll provides bothedge-triggered andlevel-triggered modes. In edge-triggered mode, a call toepoll_wait will return only when a new event is enqueued with theepoll object, while in level-triggered mode,epoll_wait will return as long as the condition holds.

For instance, if apipe registered withepoll has received data, a call toepoll_wait 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 toepoll_wait will return immediately, as long as the pipe's buffer contains data to be read. In edge-triggered mode, however,epoll_wait will return only once new data is written to the pipe.[1]

Bugs

[edit]

Bryan Cantrill pointed out thatepoll had mistakes that could have been avoided, had it learned from its predecessors:input/output completion ports,event ports (Solaris) andkqueue.[7] However, a large part of his criticism was addressed byepoll'sEPOLLONESHOT andEPOLLEXCLUSIVE options.EPOLLONESHOT was added in version 2.6.2 of the Linux kernel mainline, released in February 2004.EPOLLEXCLUSIVE was added in version 4.5, released in March 2016.[8]

See also

[edit]

References

[edit]
  1. ^ab"epoll(7) - Linux manual page". Man7.org. 2012-04-17. Retrieved2014-03-01.
  2. ^Oleksiy Kovyrin (2006-04-13)."Using epoll() For Asynchronous Network Programming". Kovyrin.net. Retrieved2014-03-01.
  3. ^"The Implementation of epoll (1)".idndx.com. September 2014.
  4. ^Love, Robert (2013).Linux System Programming (Second ed.). O’Reilly. pp. 97, 98.ISBN 978-1-449-33953-1.
  5. ^"epoll_wait: maxevents". Jun 3, 2010. Retrieved2023-07-06.
  6. ^"epoll_wait(2) — Linux manual page". 2023-03-30. Retrieved2023-07-06.
  7. ^Archived atGhostarchive and theWayback Machine:"Ubuntu Slaughters Kittens | BSD Now 103".YouTube.
  8. ^"Epoll is fundamentally broken 1/2". idea.popcount.org. 2017-02-20. Retrieved2017-10-06.

External links

[edit]
Organization
Kernel
Support
People
Technical
Debugging
Startup
ABIs
APIs
Kernel
System Call
Interface
In-kernel
Userspace
Daemons,
File systems
Wrapper
libraries
Components
Variants
Virtualization
Adoption
Range
of use
Adopters
Retrieved from "https://en.wikipedia.org/w/index.php?title=Epoll&oldid=1218866089"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp