<s>
epoll	B-Application
is	O
a	O
Linux	B-Operating_System
kernel	I-Operating_System
system	B-Operating_System
call	I-Operating_System
for	O
a	O
scalable	O
I/O	O
event	O
notification	O
mechanism	O
,	O
first	O
introduced	O
in	O
version	O
2.5.44	O
of	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
Its	O
function	O
is	O
to	O
monitor	O
multiple	O
file	B-Application
descriptors	I-Application
to	O
see	O
whether	O
I/O	O
is	O
possible	O
on	O
any	O
of	O
them	O
.	O
</s>
<s>
It	O
is	O
meant	O
to	O
replace	O
the	O
older	O
POSIX	O
select(2 )	O
and	O
poll(2 )	O
system	B-Operating_System
calls	I-Operating_System
,	O
to	O
achieve	O
better	O
performance	O
in	O
more	O
demanding	O
applications	O
,	O
where	O
the	O
number	O
of	O
watched	O
file	B-Application
descriptors	I-Application
is	O
large	O
(	O
unlike	O
the	O
older	O
system	B-Operating_System
calls	I-Operating_System
,	O
which	O
operate	O
in	O
O(n )	O
time	O
,	O
epoll	B-Application
operates	O
in	O
O(1 )	O
time	O
)	O
.	O
</s>
<s>
epoll	B-Application
is	O
similar	O
to	O
FreeBSD	B-Operating_System
's	O
kqueue	B-Application
,	O
in	O
that	O
it	O
consists	O
of	O
a	O
set	O
of	O
user-space	B-Operating_System
functions	O
,	O
each	O
taking	O
a	O
file	B-Application
descriptor	I-Application
argument	O
denoting	O
the	O
configurable	O
kernel	B-Operating_System
object	O
,	O
against	O
which	O
they	O
cooperatively	O
operate	O
.	O
</s>
<s>
epoll	B-Application
uses	O
a	O
red	O
–	O
black	O
tree	O
(	O
RB-tree	O
)	O
data	O
structure	O
to	O
keep	O
track	O
of	O
all	O
file	B-Application
descriptors	I-Application
that	O
are	O
currently	O
being	O
monitored	O
.	O
</s>
<s>
Creates	O
an	O
epoll	B-Application
object	O
and	O
returns	O
its	O
file	B-Application
descriptor	I-Application
.	O
</s>
<s>
The	O
flags	O
parameter	O
allows	O
epoll	B-Application
behavior	O
to	O
be	O
modified	O
.	O
</s>
<s>
epoll_create( )	O
is	O
an	O
older	O
variant	O
of	O
epoll_create1( )	O
and	O
is	O
deprecated	O
as	O
of	O
Linux	B-Operating_System
kernel	I-Operating_System
version	O
2.6.27	O
and	O
glibc	O
version	O
2.9	O
.	O
</s>
<s>
Controls	O
(	O
configures	O
)	O
which	O
file	B-Application
descriptors	I-Application
are	O
watched	O
by	O
this	O
object	O
,	O
and	O
for	O
which	O
events	O
.	O
</s>
<s>
epoll	B-Application
provides	O
both	O
edge-triggered	O
and	O
level-triggered	O
modes	O
.	O
</s>
<s>
In	O
edge-triggered	O
mode	O
,	O
a	O
call	O
to	O
epoll_wait	O
will	O
return	O
only	O
when	O
a	O
new	O
event	O
is	O
enqueued	O
with	O
the	O
epoll	B-Application
object	O
,	O
while	O
in	O
level-triggered	O
mode	O
,	O
epoll_wait	O
will	O
return	O
as	O
long	O
as	O
the	O
condition	O
holds	O
.	O
</s>
<s>
For	O
instance	O
,	O
if	O
a	O
pipe	B-Operating_System
registered	O
with	O
epoll	B-Application
has	O
received	O
data	O
,	O
a	O
call	O
to	O
epoll_wait	O
will	O
return	O
,	O
signaling	O
the	O
presence	O
of	O
data	O
to	O
be	O
read	O
.	O
</s>
<s>
In	O
level-triggered	O
mode	O
,	O
further	O
calls	O
to	O
epoll_wait	O
will	O
return	O
immediately	O
,	O
as	O
long	O
as	O
the	O
pipe	B-Operating_System
's	O
buffer	O
contains	O
data	O
to	O
be	O
read	O
.	O
</s>
<s>
In	O
edge-triggered	O
mode	O
,	O
however	O
,	O
epoll_wait	O
will	O
return	O
only	O
once	O
new	O
data	O
is	O
written	O
to	O
the	O
pipe	B-Operating_System
.	O
</s>
<s>
Bryan	O
Cantrill	O
pointed	O
out	O
that	O
epoll	B-Application
had	O
mistakes	O
that	O
could	O
have	O
been	O
avoided	O
,	O
had	O
it	O
learned	O
from	O
its	O
predecessors	O
:	O
input/output	B-Library
completion	I-Library
ports	I-Library
,	O
event	O
ports	O
(	O
Solaris	O
)	O
and	O
kqueue	B-Application
.	O
</s>
<s>
However	O
,	O
a	O
large	O
part	O
of	O
his	O
criticism	O
was	O
addressed	O
by	O
epoll	B-Application
's	O
EPOLLONESHOT	O
and	O
EPOLLEXCLUSIVE	O
options	O
.	O
</s>
<s>
EPOLLONESHOT	O
was	O
added	O
in	O
version	O
2.6.2	O
of	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
mainline	O
,	O
released	O
in	O
February	O
2004	O
.	O
</s>
