<s>
The	O
Interrupt	B-Device
flag	I-Device
(	O
IF	O
)	O
is	O
a	O
flag	O
bit	O
in	O
the	O
CPU	B-Device
's	O
FLAGS	B-General_Concept
register	I-General_Concept
,	O
which	O
determines	O
whether	O
or	O
not	O
the	O
(	O
CPU	B-Device
)	O
will	O
respond	O
immediately	O
to	O
maskable	O
hardware	O
interrupts	B-Application
.	O
</s>
<s>
If	O
the	O
flag	O
is	O
set	O
to	O
1	O
maskable	B-Application
interrupts	I-Application
are	O
enabled	O
.	O
</s>
<s>
If	O
reset	O
(	O
set	O
to	O
0	O
)	O
such	O
interrupts	B-Application
will	O
be	O
disabled	O
until	O
interrupts	B-Application
are	O
enabled	O
.	O
</s>
<s>
The	O
Interrupt	B-Device
flag	I-Device
does	O
not	O
affect	O
the	O
handling	O
of	O
non-maskable	B-General_Concept
interrupts	I-General_Concept
(	O
NMIs	O
)	O
or	O
software	O
interrupts	B-Application
generated	O
by	O
the	O
INT	B-Device
instruction	O
.	O
</s>
<s>
In	O
a	O
system	O
using	O
x86	B-Operating_System
architecture	I-Operating_System
,	O
the	O
instructions	O
CLI	O
(	O
Clear	O
Interrupt	B-Application
)	O
and	O
STI	O
(	O
Set	O
Interrupt	B-Application
)	O
.	O
</s>
<s>
The	O
POPF	O
(	O
Pop	O
Flags	B-General_Concept
)	O
removes	O
a	O
word	O
from	O
the	O
stack	O
into	O
the	O
FLAGS	B-General_Concept
register	I-General_Concept
,	O
which	O
may	O
result	O
in	O
the	O
Interrupt	B-Device
flag	I-Device
being	O
set	O
or	O
cleared	O
based	O
on	O
the	O
bit	O
in	O
the	O
FLAGS	B-General_Concept
register	I-General_Concept
from	O
the	O
top	O
of	O
the	O
stack	O
.	O
</s>
<s>
In	O
systems	O
that	O
support	O
privileged	O
mode	O
,	O
only	O
privileged	O
applications	O
(	O
usually	O
the	O
OS	B-Operating_System
kernel	I-Operating_System
)	O
may	O
modify	O
the	O
Interrupt	B-Device
flag	I-Device
.	O
</s>
<s>
In	O
an	O
x86	B-Operating_System
system	O
this	O
only	O
applies	O
to	O
protected	B-Application
mode	I-Application
code	O
(	O
Real	B-Application
mode	I-Application
code	O
may	O
always	O
modify	O
the	O
Interrupt	B-Device
flag	I-Device
)	O
.	O
</s>
<s>
The	O
POPF	O
instruction	O
will	O
not	O
modify	O
the	O
Interrupt	B-Device
flag	I-Device
if	O
the	O
application	O
is	O
unprivileged	O
.	O
</s>
<s>
Some	O
old	O
DOS	B-Device
programs	O
that	O
use	O
a	O
protected	B-Application
mode	I-Application
DOS	B-Device
extender	O
and	O
install	O
their	O
own	O
interrupt	B-General_Concept
handlers	I-General_Concept
(	O
usually	O
games	O
)	O
use	O
the	O
CLI	O
instruction	O
in	O
the	O
handlers	O
to	O
disable	O
interrupts	B-Application
and	O
either	O
POPF	O
(	O
after	O
a	O
corresponding	O
PUSHF	O
)	O
or	O
IRET	O
(	O
which	O
restores	O
the	O
flags	B-General_Concept
from	O
the	O
stack	O
as	O
part	O
of	O
its	O
effects	O
)	O
to	O
restore	O
it	O
.	O
</s>
<s>
This	O
works	O
if	O
the	O
program	O
was	O
started	O
in	O
real	B-Application
mode	I-Application
,	O
but	O
causes	O
problems	O
when	O
such	O
programs	O
are	O
run	O
in	O
a	O
DPMI-based	O
container	O
on	O
modern	O
operating	B-General_Concept
systems	I-General_Concept
(	O
such	O
as	O
NTVDM	O
under	O
Windows	O
NT	O
or	O
later	O
)	O
.	O
</s>
<s>
Since	O
CLI	O
is	O
a	O
privileged	O
instruction	O
,	O
it	O
triggers	O
a	O
fault	O
into	O
the	O
operating	B-General_Concept
system	I-General_Concept
when	O
the	O
program	O
attempts	O
to	O
use	O
it	O
.	O
</s>
<s>
The	O
OS	O
then	O
typically	O
stops	O
delivering	O
interrupts	B-Application
to	O
the	O
program	O
until	O
the	O
program	O
executes	O
STI	O
(	O
which	O
would	O
cause	O
another	O
fault	O
)	O
.	O
</s>
<s>
The	O
result	O
is	O
that	O
the	O
OS	O
stops	O
delivering	O
interrupts	B-Application
to	O
the	O
program	O
,	O
which	O
then	O
hangs	O
.	O
</s>
<s>
DOS	B-Device
programs	O
that	O
do	O
not	O
use	O
a	O
protected	B-Application
mode	I-Application
extender	O
do	O
not	O
suffer	O
from	O
this	O
problem	O
,	O
as	O
they	O
execute	O
in	O
V86	O
mode	O
where	O
POPF	O
does	O
trigger	O
a	O
fault	O
.	O
</s>
<s>
Removing	O
CLI	O
's	O
from	O
the	O
program	O
or	O
causing	O
the	O
V86	O
host	O
to	O
ignore	O
CLI	O
completely	O
might	O
cause	O
other	O
bugs	O
if	O
the	O
guest	O
's	O
interrupt	B-General_Concept
handlers	I-General_Concept
are	O
n't	O
designed	O
to	O
be	O
re-entrant	O
(	O
though	O
when	O
executed	O
on	O
a	O
modern	O
processor	O
,	O
they	O
typically	O
execute	O
fast	O
enough	O
to	O
avoid	O
overlapping	O
of	O
interrupts	B-Application
)	O
.	O
</s>
<s>
In	O
the	O
x86	B-Operating_System
instruction	B-General_Concept
set	I-General_Concept
CLI	O
is	O
commonly	O
used	O
as	O
a	O
synchronization	O
mechanism	O
in	O
uniprocessor	O
systems	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
CLI	O
is	O
used	O
in	O
operating	B-General_Concept
systems	I-General_Concept
to	O
disable	O
interrupts	B-Application
so	O
kernel	B-Operating_System
code	O
(	O
typically	O
a	O
driver	B-Application
)	O
can	O
avoid	O
race	O
conditions	O
within	O
an	O
interrupt	B-General_Concept
handler	I-General_Concept
.	O
</s>
<s>
The	O
STI	O
of	O
the	O
x86	B-Operating_System
instruction	B-General_Concept
set	I-General_Concept
enables	O
interrupts	B-Application
by	O
setting	O
the	O
IF	O
.	O
</s>
<s>
In	O
some	O
implementations	O
of	O
the	O
instruction	O
which	O
enables	O
interrupts	B-Application
,	O
interrupts	B-Application
are	O
not	O
enabled	O
until	O
after	O
the	O
next	O
instruction	O
.	O
</s>
<s>
In	O
this	O
case	O
the	O
sequence	O
of	O
enabling	O
interrupts	B-Application
immediately	O
followed	O
by	O
disabling	O
interrupts	B-Application
results	O
in	O
interrupts	B-Application
not	O
being	O
recognized	O
.	O
</s>
<s>
The	O
Interrupt	B-Device
flag	I-Device
only	O
affects	O
a	O
single	O
processor	O
.	O
</s>
<s>
In	O
multiprocessor	B-Operating_System
systems	O
an	O
interrupt	B-General_Concept
handler	I-General_Concept
must	O
use	O
other	O
synchronization	O
mechanisms	O
such	O
as	O
locks	B-Operating_System
.	O
</s>
