<s>
In	O
computing	O
,	O
protected	B-Application
mode	I-Application
,	O
also	O
called	O
protected	B-Application
virtual	I-Application
address	I-Application
mode	I-Application
,	O
is	O
an	O
operational	O
mode	O
of	O
x86-compatible	O
central	B-General_Concept
processing	I-General_Concept
units	I-General_Concept
(	O
CPUs	O
)	O
.	O
</s>
<s>
It	O
allows	O
system	B-Application
software	I-Application
to	O
use	O
features	O
such	O
as	O
virtual	B-Architecture
memory	I-Architecture
,	O
paging	B-Architecture
and	O
safe	O
multi-tasking	B-Operating_System
designed	O
to	O
increase	O
an	O
operating	B-General_Concept
system	I-General_Concept
's	O
control	O
over	O
application	B-Application
software	I-Application
.	O
</s>
<s>
When	O
a	O
processor	O
that	O
supports	O
x86	B-Operating_System
protected	B-Application
mode	I-Application
is	O
powered	O
on	O
,	O
it	O
begins	O
executing	O
instructions	O
in	O
real	B-Application
mode	I-Application
,	O
in	O
order	O
to	O
maintain	O
backward	B-General_Concept
compatibility	I-General_Concept
with	O
earlier	O
x86	B-Operating_System
processors	O
.	O
</s>
<s>
Protected	B-Application
mode	I-Application
may	O
only	O
be	O
entered	O
after	O
the	O
system	B-Application
software	I-Application
sets	O
up	O
one	O
descriptor	O
table	O
and	O
enables	O
the	O
Protection	O
Enable	O
(	O
PE	O
)	O
bit	O
in	O
the	O
control	B-Operating_System
register	I-Operating_System
0	O
(	O
CR0	B-Operating_System
)	O
.	O
</s>
<s>
Protected	B-Application
mode	I-Application
was	O
first	O
added	O
to	O
the	O
x86	B-Operating_System
architecture	I-Operating_System
in	O
1982	O
,	O
with	O
the	O
release	O
of	O
Intel	O
's	O
80286	B-General_Concept
(	O
286	B-General_Concept
)	O
processor	O
,	O
and	O
later	O
extended	O
with	O
the	O
release	O
of	O
the	O
80386	B-General_Concept
(	O
386	B-General_Concept
)	O
in	O
1985	O
.	O
</s>
<s>
Due	O
to	O
the	O
enhancements	O
added	O
by	O
protected	B-Application
mode	I-Application
,	O
it	O
has	O
become	O
widely	O
adopted	O
and	O
has	O
become	O
the	O
foundation	O
for	O
all	O
subsequent	O
enhancements	O
to	O
the	O
x86	B-Operating_System
architecture	I-Operating_System
,	O
although	O
many	O
of	O
those	O
enhancements	O
,	O
such	O
as	O
added	O
instructions	O
and	O
new	O
registers	O
,	O
also	O
brought	O
benefits	O
to	O
the	O
real	B-Application
mode	I-Application
.	O
</s>
<s>
The	O
Intel	B-General_Concept
8086	I-General_Concept
,	O
the	O
predecessor	O
to	O
the	O
286	B-General_Concept
,	O
was	O
originally	O
designed	O
with	O
a	O
20-bit	O
address	B-Architecture
bus	I-Architecture
for	O
its	O
memory	B-General_Concept
.	O
</s>
<s>
This	O
allowed	O
the	O
processor	O
to	O
access	O
220	O
bytes	B-Application
of	O
memory	B-General_Concept
,	O
equivalent	O
to	O
1	O
megabyte	O
.	O
</s>
<s>
At	O
the	O
time	O
,	O
1	O
megabyte	O
was	O
considered	O
a	O
relatively	O
large	O
amount	O
of	O
memory	B-General_Concept
,	O
so	O
the	O
designers	O
of	O
the	O
IBM	B-Device
Personal	I-Device
Computer	I-Device
reserved	O
the	O
first	O
640	O
kilobytes	O
for	O
use	O
by	O
applications	O
and	O
the	O
operating	B-General_Concept
system	I-General_Concept
and	O
the	B-Device
remaining	I-Device
384	I-Device
kilobytes	I-Device
for	O
the	O
BIOS	B-Operating_System
(	O
Basic	B-Operating_System
Input/Output	I-Operating_System
System	I-Operating_System
)	O
and	O
memory	B-General_Concept
for	O
add-on	O
devices	O
.	O
</s>
<s>
As	O
the	O
cost	O
of	O
memory	B-General_Concept
decreased	O
and	O
memory	B-General_Concept
use	O
increased	O
,	O
the	O
1	O
MB	O
limitation	O
became	O
a	O
significant	O
problem	O
.	O
</s>
<s>
Intel	O
intended	O
to	O
solve	O
this	O
limitation	O
along	O
with	O
others	O
with	O
the	O
release	O
of	O
the	O
286	B-General_Concept
.	O
</s>
<s>
The	O
initial	O
protected	B-Application
mode	I-Application
,	O
released	O
with	O
the	O
286	B-General_Concept
,	O
was	O
not	O
widely	O
used	O
;	O
for	O
example	O
,	O
it	O
was	O
used	O
by	O
Coherent	B-Operating_System
(	O
from	O
1982	O
)	O
,	O
Microsoft	B-Application
Xenix	I-Application
(	O
around	O
1984	O
)	O
and	O
Minix	B-Operating_System
.	O
</s>
<s>
Several	O
shortcomings	O
such	O
as	O
the	O
inability	O
to	O
access	O
the	O
BIOS	B-Operating_System
or	O
DOS	B-Device
calls	O
due	O
to	O
inability	O
to	O
switch	O
back	O
to	O
real	B-Application
mode	I-Application
without	O
resetting	O
the	O
processor	O
prevented	O
widespread	O
usage	O
.	O
</s>
<s>
Acceptance	O
was	O
additionally	O
hampered	O
by	O
the	O
fact	O
that	O
the	O
286	B-General_Concept
only	O
allowed	O
memory	B-General_Concept
access	O
in	O
16	O
bit	O
segments	O
via	O
each	O
of	O
four	O
segment	B-General_Concept
registers	I-General_Concept
,	O
meaning	O
only	O
4*216	O
bytes	B-Application
,	O
equivalent	O
to	O
256	O
kilobytes	O
,	O
could	O
be	O
accessed	O
at	O
a	O
time	O
.	O
</s>
<s>
Because	O
changing	O
a	O
segment	B-General_Concept
register	I-General_Concept
in	O
protected	B-Application
mode	I-Application
caused	O
a	O
6-byte	O
segment	B-General_Concept
descriptor	O
to	O
be	O
loaded	O
into	O
the	O
CPU	O
from	O
memory	B-General_Concept
,	O
the	O
segment	B-General_Concept
register	I-General_Concept
load	O
instruction	O
took	O
many	O
tens	O
of	O
processor	O
cycles	O
,	O
making	O
it	O
much	O
slower	O
than	O
on	O
the	O
8086	B-General_Concept
;	O
therefore	O
,	O
the	O
strategy	O
of	O
computing	O
segment	B-General_Concept
addresses	O
on-the-fly	O
in	O
order	O
to	O
access	O
data	O
structures	O
larger	O
than	O
128	O
kilobytes	O
(	O
the	O
combined	O
size	O
of	O
the	O
two	O
data	O
segments	O
)	O
became	O
impractical	O
,	O
even	O
for	O
those	O
few	O
programmers	O
who	O
had	O
mastered	O
it	O
on	O
the	O
8086/8088	O
.	O
</s>
<s>
The	O
286	B-General_Concept
maintained	O
backwards	B-General_Concept
compatibility	I-General_Concept
with	O
its	O
precursor	O
the	O
8086	B-General_Concept
by	O
initially	O
entering	O
real	B-Application
mode	I-Application
on	O
power	O
up	O
.	O
</s>
<s>
Real	B-Application
mode	I-Application
functioned	O
virtually	O
identically	O
to	O
the	O
8086	B-General_Concept
,	O
allowing	O
the	O
vast	O
majority	O
of	O
existing	O
8086	B-General_Concept
software	O
to	O
run	O
unmodified	O
on	O
the	O
newer	O
286	B-General_Concept
.	O
</s>
<s>
Real	B-Application
mode	I-Application
also	O
served	O
as	O
a	O
more	O
basic	O
mode	O
in	O
which	O
protected	B-Application
mode	I-Application
could	O
be	O
set	O
up	O
,	O
solving	O
a	O
sort	O
of	O
chicken-and-egg	O
problem	O
.	O
</s>
<s>
To	O
access	O
the	O
extended	O
functionality	O
of	O
the	O
286	B-General_Concept
,	O
the	O
operating	B-General_Concept
system	I-General_Concept
would	O
set	O
up	O
some	O
tables	O
in	O
memory	B-General_Concept
that	O
controlled	O
memory	B-General_Concept
access	O
in	O
protected	B-Application
mode	I-Application
,	O
set	O
the	O
addresses	O
of	O
those	O
tables	O
into	O
some	O
special	O
registers	O
of	O
the	O
processor	O
,	O
and	O
then	O
set	O
the	O
processor	O
into	O
protected	B-Application
mode	I-Application
.	O
</s>
<s>
This	O
enabled	O
24	O
bit	O
addressing	O
which	O
allowed	O
the	O
processor	O
to	O
access	O
224	O
bytes	B-Application
of	O
memory	B-General_Concept
,	O
equivalent	O
to	O
16	O
megabytes	O
.	O
</s>
<s>
With	O
the	O
release	O
of	O
the	O
386	B-General_Concept
in	O
1985	O
,	O
many	O
of	O
the	O
issues	O
preventing	O
widespread	O
adoption	O
of	O
the	O
previous	O
protected	B-Application
mode	I-Application
were	O
addressed	O
.	O
</s>
<s>
The	O
386	B-General_Concept
was	O
released	O
with	O
an	O
address	B-Architecture
bus	I-Architecture
size	O
of	O
32	O
bits	O
,	O
which	O
allows	O
for	O
232	O
bytes	B-Application
of	O
memory	B-General_Concept
accessing	O
,	O
equivalent	O
to	O
4	O
gigabytes	O
.	O
</s>
<s>
The	O
segment	B-General_Concept
sizes	O
were	O
also	O
increased	O
to	O
32	O
bits	O
,	O
meaning	O
that	O
the	O
full	O
address	B-General_Concept
space	I-General_Concept
of	O
4	O
gigabytes	O
could	O
be	O
accessed	O
without	O
the	O
need	O
to	O
switch	O
between	O
multiple	O
segments	O
.	O
</s>
<s>
In	O
addition	O
to	O
the	O
increased	O
size	O
of	O
the	O
address	B-Architecture
bus	I-Architecture
and	O
segment	B-General_Concept
registers	I-General_Concept
,	O
many	O
other	O
new	O
features	O
were	O
added	O
with	O
the	O
intention	O
of	O
increasing	O
operational	O
security	O
and	O
stability	O
.	O
</s>
<s>
Protected	B-Application
mode	I-Application
is	O
now	O
used	O
in	O
virtually	O
all	O
modern	O
operating	B-General_Concept
systems	I-General_Concept
which	O
run	O
on	O
the	O
x86	B-Operating_System
architecture	I-Operating_System
,	O
such	O
as	O
Microsoft	B-Application
Windows	I-Application
,	O
Linux	B-Application
,	O
and	O
many	O
others	O
.	O
</s>
<s>
Furthermore	O
,	O
learning	O
from	O
the	O
failures	O
of	O
the	O
286	B-Application
protected	I-Application
mode	I-Application
to	O
satisfy	O
the	O
needs	O
for	O
multiuser	B-Operating_System
DOS	I-Operating_System
,	O
Intel	O
added	O
a	O
separate	O
virtual	B-Application
8086	I-Application
mode	I-Application
,	O
which	O
allowed	O
multiple	O
virtualized	O
8086	B-General_Concept
processors	O
to	O
be	O
emulated	O
on	O
the	O
386	B-General_Concept
.	O
</s>
<s>
Hardware	B-General_Concept
x86	I-General_Concept
virtualization	I-General_Concept
required	O
for	O
virtualizing	O
the	O
protected	B-Application
mode	I-Application
itself	O
,	O
however	O
,	O
had	O
to	O
wait	O
for	O
another	O
20	O
years	O
.	O
</s>
<s>
With	O
the	O
release	O
of	O
the	O
386	B-General_Concept
,	O
the	O
following	O
additional	O
features	O
were	O
added	O
to	O
protected	B-Application
mode	I-Application
:	O
</s>
<s>
32-bit	O
physical	O
and	O
virtual	O
address	B-General_Concept
space	I-General_Concept
(	O
The	O
32-bit	O
physical	O
address	B-General_Concept
space	I-General_Concept
is	O
not	O
present	O
on	O
the	O
80386SX	O
,	O
and	O
other	O
386	B-General_Concept
processor	O
variants	O
which	O
use	O
the	O
older	O
286	B-General_Concept
bus	O
.	O
)	O
</s>
<s>
Until	O
the	O
release	O
of	O
the	O
386	B-General_Concept
,	O
protected	B-Application
mode	I-Application
did	O
not	O
offer	O
a	O
direct	O
method	O
to	O
switch	O
back	O
into	O
real	B-Application
mode	I-Application
once	O
protected	B-Application
mode	I-Application
was	O
entered	O
.	O
</s>
<s>
IBM	O
devised	O
a	O
workaround	O
(	O
implemented	O
in	O
the	O
IBM	B-Operating_System
AT	I-Operating_System
)	O
which	O
involved	O
resetting	O
the	O
CPU	O
via	O
the	O
keyboard	O
controller	O
and	O
saving	O
the	O
system	O
registers	O
,	O
stack	B-General_Concept
pointer	I-General_Concept
and	O
often	O
the	O
interrupt	B-Application
mask	I-Application
in	O
the	O
real-time	O
clock	O
chip	O
's	O
RAM	O
.	O
</s>
<s>
This	O
allowed	O
the	O
BIOS	B-Operating_System
to	O
restore	O
the	O
CPU	O
to	O
a	O
similar	O
state	O
and	O
begin	O
executing	O
code	O
before	O
the	O
reset	O
.	O
</s>
<s>
Later	O
,	O
a	O
triple	B-Error_Name
fault	I-Error_Name
was	O
used	O
to	O
reset	O
the	O
286	B-General_Concept
CPU	O
,	O
which	O
was	O
a	O
lot	O
faster	O
and	O
cleaner	O
than	O
the	O
keyboard	O
controller	O
method	O
(	O
and	O
does	O
not	O
depend	O
on	O
IBM	O
AT-compatible	O
hardware	O
,	O
but	O
will	O
work	O
on	O
any	O
80286	B-General_Concept
CPU	O
in	O
any	O
system	O
)	O
.	O
</s>
<s>
To	O
enter	O
protected	B-Application
mode	I-Application
,	O
the	O
Global	B-General_Concept
Descriptor	I-General_Concept
Table	I-General_Concept
(	O
GDT	O
)	O
must	O
first	O
be	O
created	O
with	O
a	O
minimum	O
of	O
three	O
entries	O
:	O
a	O
null	O
descriptor	O
,	O
a	O
code	O
segment	B-General_Concept
descriptor	O
and	O
data	O
segment	B-General_Concept
descriptor	O
.	O
</s>
<s>
In	O
an	O
IBM-compatible	O
machine	O
,	O
the	O
A20	B-Device
line	I-Device
(	O
21st	O
address	O
line	O
)	O
also	O
must	O
be	O
enabled	O
to	O
allow	O
the	O
use	O
of	O
all	O
the	O
address	O
lines	O
so	O
that	O
the	O
CPU	O
can	O
access	O
beyond	O
1	O
megabyte	O
of	O
memory	B-General_Concept
(	O
Only	O
the	O
first	O
20	O
are	O
allowed	O
to	O
be	O
used	O
after	O
power-up	O
,	O
to	O
guarantee	O
compatibility	O
with	O
older	O
software	O
written	O
for	O
the	O
Intel	O
8088-based	O
IBM	B-Device
PC	I-Device
and	O
PC/XT	B-Device
models	O
)	O
.	O
</s>
<s>
After	O
performing	O
those	O
two	O
steps	O
,	O
the	O
PE	O
bit	O
must	O
be	O
set	O
in	O
the	O
CR0	B-Operating_System
register	O
and	O
a	O
far	O
jump	O
must	O
be	O
made	O
to	O
clear	O
the	O
prefetch	B-General_Concept
input	I-General_Concept
queue	I-General_Concept
.	O
</s>
<s>
With	O
the	O
release	O
of	O
the	O
386	B-General_Concept
,	O
protected	B-Application
mode	I-Application
could	O
be	O
exited	O
by	O
loading	O
the	O
segment	B-General_Concept
registers	I-General_Concept
with	O
real	B-Application
mode	I-Application
values	O
,	O
disabling	O
the	O
A20	B-Device
line	I-Device
and	O
clearing	O
the	O
PE	O
bit	O
in	O
the	O
CR0	B-Operating_System
register	O
,	O
without	O
the	O
need	O
to	O
perform	O
the	O
initial	O
setup	O
steps	O
required	O
with	O
the	O
286	B-General_Concept
.	O
</s>
<s>
Protected	B-Application
mode	I-Application
has	O
a	O
number	O
of	O
features	O
designed	O
to	O
enhance	O
an	O
operating	B-General_Concept
system	I-General_Concept
's	O
control	O
over	O
application	B-Application
software	I-Application
,	O
in	O
order	O
to	O
increase	O
security	O
and	O
system	O
stability	O
.	O
</s>
<s>
These	O
additions	O
allow	O
the	O
operating	B-General_Concept
system	I-General_Concept
to	O
function	O
in	O
a	O
way	O
that	O
would	O
be	O
significantly	O
more	O
difficult	O
or	O
even	O
impossible	O
without	O
proper	O
hardware	O
support	O
.	O
</s>
<s>
In	O
protected	B-Application
mode	I-Application
,	O
there	O
are	O
four	O
privilege	B-Operating_System
levels	I-Operating_System
or	O
rings	O
,	O
numbered	O
from	O
0	O
to	O
3	O
,	O
with	O
ring	B-Operating_System
0	I-Operating_System
being	O
the	O
most	O
privileged	O
and	O
3	O
being	O
the	O
least	O
.	O
</s>
<s>
The	O
use	O
of	O
rings	O
allows	O
for	O
system	B-Application
software	I-Application
to	O
restrict	O
tasks	O
from	O
accessing	O
data	O
,	O
call	B-Device
gates	I-Device
or	O
executing	O
privileged	O
instructions	O
.	O
</s>
<s>
In	O
most	O
environments	O
,	O
the	O
operating	B-General_Concept
system	I-General_Concept
and	O
some	O
device	B-Application
drivers	I-Application
run	O
in	O
ring	B-Operating_System
0	I-Operating_System
and	O
applications	O
run	O
in	O
ring	B-Operating_System
3	I-Operating_System
.	O
</s>
<s>
According	O
to	O
the	O
Intel	B-General_Concept
80286	I-General_Concept
Programmer	O
's	O
Reference	O
Manual	O
,	O
</s>
<s>
For	O
the	O
most	O
part	O
,	O
the	O
binary	O
compatibility	O
with	O
real-mode	B-Application
code	O
,	O
the	O
ability	O
to	O
access	O
up	O
to	O
16	O
MB	O
of	O
physical	O
memory	B-General_Concept
,	O
and	O
1	O
GB	O
of	O
virtual	B-Architecture
memory	I-Architecture
,	O
were	O
the	O
most	O
apparent	O
changes	O
to	O
application	O
programmers	O
.	O
</s>
<s>
In	O
reality	O
,	O
almost	O
all	O
DOS	B-Device
application	B-Application
programs	I-Application
violated	O
these	O
rules	O
.	O
</s>
<s>
Due	O
to	O
these	O
limitations	O
,	O
virtual	B-Application
8086	I-Application
mode	I-Application
was	O
introduced	O
with	O
the	O
386	B-General_Concept
.	O
</s>
<s>
Despite	O
such	O
potential	O
setbacks	O
,	O
Windows	B-Application
3.0	I-Application
and	O
its	O
successors	O
can	O
take	O
advantage	O
of	O
the	O
binary	O
compatibility	O
with	O
real	B-Application
mode	I-Application
to	O
run	O
many	O
Windows	O
2.x	O
(	O
Windows	B-Application
2.0	I-Application
and	O
Windows	B-Application
2.1x	I-Application
)	O
applications	O
in	O
protected	B-Application
mode	I-Application
,	O
which	O
ran	O
in	O
real	B-Application
mode	I-Application
in	O
Windows	O
2.x	O
.	O
</s>
<s>
With	O
the	O
release	O
of	O
the	O
386	B-General_Concept
,	O
protected	B-Application
mode	I-Application
offers	O
what	O
the	O
Intel	O
manuals	O
call	O
virtual	B-Application
8086	I-Application
mode	I-Application
.	O
</s>
<s>
Virtual	B-Application
8086	I-Application
mode	I-Application
is	O
designed	O
to	O
allow	O
code	O
previously	O
written	O
for	O
the	O
8086	B-General_Concept
to	O
run	O
unmodified	O
and	O
concurrently	O
with	O
other	O
tasks	O
,	O
without	O
compromising	O
security	O
or	O
system	O
stability	O
.	O
</s>
<s>
Virtual	B-Application
8086	I-Application
mode	I-Application
,	O
however	O
,	O
is	O
not	O
completely	O
backwards	B-General_Concept
compatible	I-General_Concept
with	O
all	O
programs	O
.	O
</s>
<s>
Programs	O
that	O
require	O
segment	B-General_Concept
manipulation	O
,	O
privileged	O
instructions	O
,	O
direct	O
hardware	O
access	O
,	O
or	O
use	O
self-modifying	B-Application
code	I-Application
will	O
generate	O
an	O
exception	B-General_Concept
that	O
must	O
be	O
served	O
by	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
In	O
addition	O
,	O
applications	O
running	O
in	O
virtual	B-Application
8086	I-Application
mode	I-Application
generate	O
a	O
trap	B-Application
with	O
the	O
use	O
of	O
instructions	O
that	O
involve	O
input/output	B-General_Concept
(	O
I/O	B-General_Concept
)	O
,	O
which	O
can	O
negatively	O
impact	O
performance	O
.	O
</s>
<s>
Due	O
to	O
these	O
limitations	O
,	O
some	O
programs	O
originally	O
designed	O
to	O
run	O
on	O
the	O
8086	B-General_Concept
cannot	O
be	O
run	O
in	O
virtual	B-Application
8086	I-Application
mode	I-Application
.	O
</s>
<s>
As	O
a	O
result	O
,	O
system	B-Application
software	I-Application
is	O
forced	O
to	O
either	O
compromise	O
system	O
security	O
or	O
backwards	B-General_Concept
compatibility	I-General_Concept
when	O
dealing	O
with	O
legacy	B-Device
software	I-Device
.	O
</s>
<s>
An	O
example	O
of	O
such	O
a	O
compromise	O
can	O
be	O
seen	O
with	O
the	O
release	O
of	O
Windows	B-Device
NT	I-Device
,	O
which	O
dropped	O
backwards	B-General_Concept
compatibility	I-General_Concept
for	O
"	O
ill-behaved	O
"	O
DOS	B-Device
applications	O
.	O
</s>
<s>
In	O
real	B-Application
mode	I-Application
each	O
logical	O
address	O
points	O
directly	O
into	O
a	O
physical	O
memory	B-General_Concept
location	O
,	O
every	O
logical	O
address	O
consists	O
of	O
two	O
16	O
bit	O
parts	O
:	O
The	O
segment	B-General_Concept
part	O
of	O
the	O
logical	O
address	O
contains	O
the	O
base	O
address	O
of	O
a	O
segment	B-General_Concept
with	O
a	O
granularity	O
of	O
16	O
bytes	B-Application
,	O
i.e.	O
</s>
<s>
a	O
segment	B-General_Concept
may	O
start	O
at	O
physical	O
address	O
0	O
,	O
16	O
,	O
32	O
,	O
...	O
,	O
220-16	O
.	O
</s>
<s>
The	O
offset	O
part	O
of	O
the	O
logical	O
address	O
contains	O
an	O
offset	O
inside	O
the	O
segment	B-General_Concept
,	O
i.e.	O
</s>
<s>
the	O
physical	O
address	O
can	O
be	O
calculated	O
as	O
physical_address	O
:	O
=	O
segment_part	O
×	O
16	O
+	O
offset	O
(	O
if	O
the	O
address	O
line	B-Device
A20	I-Device
is	O
enabled	O
)	O
,	O
respectively	O
(	O
segment_part	O
×	O
16	O
+	O
offset	O
)	O
mod	O
220	O
(	O
if	O
A20	O
is	O
off	O
)	O
Every	O
segment	B-General_Concept
has	O
a	O
size	O
of	O
216	O
bytes	B-Application
.	O
</s>
<s>
In	O
protected	B-Application
mode	I-Application
,	O
the	O
is	O
replaced	O
by	O
a	O
16-bit	O
selector	O
,	O
in	O
which	O
the	O
13	O
upper	O
bits	O
(	O
bit	O
3	O
to	O
bit	O
15	O
)	O
contain	O
the	O
index	O
of	O
an	O
entry	O
inside	O
a	O
descriptor	O
table	O
.	O
</s>
<s>
This	O
means	O
that	O
the	O
byte	B-Application
offset	O
of	O
descriptors	O
in	O
the	O
descriptor	O
table	O
is	O
the	O
same	O
as	O
the	O
16-bit	O
selector	O
,	O
provided	O
the	O
lower	O
three	O
bits	O
are	O
zeroed	O
.	O
</s>
<s>
The	O
descriptor	O
table	O
entry	O
defines	O
the	O
real	O
linear	O
address	O
of	O
the	O
segment	B-General_Concept
,	O
a	O
limit	O
value	O
for	O
the	O
segment	B-General_Concept
size	O
,	O
and	O
some	O
attribute	O
bits	O
(	O
flags	O
)	O
.	O
</s>
<s>
The	O
segment	B-General_Concept
address	O
inside	O
the	O
descriptor	O
table	O
entry	O
has	O
a	O
length	O
of	O
24	O
bits	O
so	O
every	O
byte	B-Application
of	O
the	O
physical	O
memory	B-General_Concept
can	O
be	O
defined	O
as	O
bound	O
of	O
the	O
segment	B-General_Concept
.	O
</s>
<s>
The	O
limit	O
value	O
inside	O
the	O
descriptor	O
table	O
entry	O
has	O
a	O
length	O
of	O
16	O
bits	O
so	O
segment	B-General_Concept
length	O
can	O
be	O
between	O
1	O
byte	B-Application
and	O
216	O
byte	B-Application
.	O
</s>
<s>
The	O
calculated	O
linear	O
address	O
equals	O
the	O
physical	O
memory	B-General_Concept
address	O
.	O
</s>
<s>
The	O
segment	B-General_Concept
address	O
inside	O
the	O
descriptor	O
table	O
entry	O
is	O
expanded	O
to	O
32	O
bits	O
so	O
every	O
byte	B-Application
of	O
the	O
physical	O
memory	B-General_Concept
can	O
be	O
defined	O
as	O
bound	O
of	O
the	O
segment	B-General_Concept
.	O
</s>
<s>
If	O
G-bit	O
is	O
zero	O
limit	O
has	O
a	O
granularity	O
of	O
1	O
byte	B-Application
,	O
i.e.	O
</s>
<s>
segment	B-General_Concept
size	O
may	O
be	O
1	O
,	O
2	O
,	O
...	O
,	O
220	O
bytes	B-Application
.	O
</s>
<s>
If	O
G-bit	O
is	O
one	O
limit	O
has	O
a	O
granularity	O
of	O
212	O
bytes	B-Application
,	O
i.e.	O
</s>
<s>
segment	B-General_Concept
size	O
may	O
be	O
1	O
×	O
212	O
,	O
2	O
×	O
212	O
,	O
...	O
,	O
220	O
×	O
212	O
bytes	B-Application
.	O
</s>
<s>
If	O
paging	B-Architecture
is	O
off	O
,	O
the	O
calculated	O
linear	O
address	O
equals	O
the	O
physical	O
memory	B-General_Concept
address	O
.	O
</s>
<s>
If	O
paging	B-Architecture
is	O
on	O
,	O
the	O
calculated	O
linear	O
address	O
is	O
used	O
as	O
input	O
of	O
paging	B-Architecture
.	O
</s>
<s>
The	O
386	B-General_Concept
processor	O
also	O
uses	O
32	O
bit	O
values	O
for	O
the	O
address	O
offset	O
.	O
</s>
<s>
For	O
maintaining	O
compatibility	O
with	O
286	B-Application
protected	I-Application
mode	I-Application
a	O
new	O
default	O
flag	O
(	O
D-bit	O
,	O
for	O
short	O
)	O
was	O
added	O
.	O
</s>
<s>
If	O
the	O
D-bit	O
of	O
a	O
code	O
segment	B-General_Concept
is	O
off	O
(	O
0	O
)	O
all	O
commands	O
inside	O
this	O
segment	B-General_Concept
will	O
be	O
interpreted	O
as	O
16-bit	O
commands	O
by	O
default	O
;	O
if	O
it	O
is	O
on	O
(	O
1	O
)	O
,	O
they	O
will	O
be	O
interpreted	O
as	O
32-bit	O
commands	O
.	O
</s>
<s>
if	O
X	O
=	O
1	O
then	O
C	O
is	O
the	O
Conforming	O
bit	O
,	O
and	O
determines	O
which	O
privilege	B-Operating_System
levels	I-Operating_System
can	O
far-jump	O
to	O
this	O
segment	B-General_Concept
(	O
without	O
changing	O
privilege	O
level	O
)	O
:	O
</s>
<s>
if	O
C	O
=	O
0	O
then	O
the	O
segment	B-General_Concept
grows	O
up	O
;	O
</s>
<s>
if	O
C	O
=	O
1	O
then	O
the	O
segment	B-General_Concept
grows	O
down	O
.	O
</s>
<s>
if	O
X	O
=	O
1	O
then	O
the	O
segment	B-General_Concept
is	O
a	O
code	O
segment	B-General_Concept
;	O
</s>
<s>
if	O
X	O
=	O
0	O
then	O
the	O
segment	B-General_Concept
is	O
a	O
data	O
segment	B-General_Concept
.	O
</s>
<s>
S	O
is	O
the	O
Segment	B-General_Concept
type	O
bit	O
,	O
which	O
should	O
generally	O
be	O
cleared	O
for	O
system	O
segments	O
;	O
</s>
<s>
Bit	O
52	O
of	O
the	O
80386	B-General_Concept
descriptor	O
is	O
not	O
used	O
by	O
the	O
hardware	O
.	O
</s>
<s>
In	O
addition	O
to	O
adding	O
virtual	B-Application
8086	I-Application
mode	I-Application
,	O
the	O
386	B-General_Concept
also	O
added	O
paging	B-Architecture
to	O
protected	B-Application
mode	I-Application
.	O
</s>
<s>
Through	O
paging	B-Architecture
,	O
system	B-Application
software	I-Application
can	O
restrict	O
and	O
control	O
a	O
task	O
's	O
access	O
to	O
pages	O
,	O
which	O
are	O
sections	O
of	O
memory	B-General_Concept
.	O
</s>
<s>
In	O
many	O
operating	B-General_Concept
systems	I-General_Concept
,	O
paging	B-Architecture
is	O
used	O
to	O
create	O
an	O
independent	O
virtual	O
address	B-General_Concept
space	I-General_Concept
for	O
each	O
task	O
,	O
preventing	O
one	O
task	O
from	O
manipulating	O
the	O
memory	B-General_Concept
of	O
another	O
.	O
</s>
<s>
Paging	B-Architecture
also	O
allows	O
for	O
pages	O
to	O
be	O
moved	O
out	O
of	O
primary	O
storage	O
and	O
onto	O
a	O
slower	O
and	O
larger	O
secondary	O
storage	O
,	O
such	O
as	O
a	O
hard	B-Device
disk	I-Device
drive	I-Device
.	O
</s>
<s>
This	O
allows	O
for	O
more	O
memory	B-General_Concept
to	O
be	O
used	O
than	O
physically	O
available	O
in	O
primary	O
storage	O
.	O
</s>
<s>
The	O
x86	B-Operating_System
architecture	I-Operating_System
allows	O
control	O
of	O
pages	O
through	O
two	O
arrays	O
:	O
page	O
directories	O
and	O
page	B-General_Concept
tables	I-General_Concept
.	O
</s>
<s>
Originally	O
,	O
a	O
page	O
directory	O
was	O
the	O
size	O
of	O
one	O
page	O
,	O
four	O
kilobytes	O
,	O
and	O
contained	O
1,024	O
page	O
directory	O
entries	O
(	O
PDE	O
)	O
,	O
although	O
subsequent	O
enhancements	O
to	O
the	O
x86	B-Operating_System
architecture	I-Operating_System
have	O
added	O
the	O
ability	O
to	O
use	O
larger	O
page	O
sizes	O
.	O
</s>
<s>
Each	O
PDE	O
contained	O
a	O
pointer	O
to	O
a	O
page	B-General_Concept
table	I-General_Concept
.	O
</s>
<s>
A	O
page	B-General_Concept
table	I-General_Concept
was	O
also	O
originally	O
four	O
kilobytes	O
in	O
size	O
and	O
contained	O
1,024	O
page	B-General_Concept
table	I-General_Concept
entries	O
(	O
PTE	O
)	O
.	O
</s>
<s>
Through	O
the	O
use	O
of	O
the	O
rings	O
,	O
privileged	O
call	B-Device
gates	I-Device
,	O
and	O
the	O
Task	B-Device
State	I-Device
Segment	I-Device
(	O
TSS	O
)	O
,	O
introduced	O
with	O
the	O
286	B-General_Concept
,	O
preemptive	O
multitasking	B-Operating_System
was	O
made	O
possible	O
on	O
the	O
x86	B-Operating_System
architecture	I-Operating_System
.	O
</s>
<s>
The	O
TSS	O
allows	O
general-purpose	O
registers	O
,	O
segment	B-General_Concept
selector	O
fields	O
,	O
and	O
stacks	O
to	O
all	O
be	O
modified	O
without	O
affecting	O
those	O
of	O
another	O
task	O
.	O
</s>
<s>
The	O
TSS	O
also	O
allows	O
a	O
task	O
's	O
privilege	O
level	O
,	O
and	O
I/O	B-General_Concept
port	O
permissions	O
to	O
be	O
independent	O
of	O
another	O
task	O
's	O
.	O
</s>
<s>
In	O
many	O
operating	B-General_Concept
systems	I-General_Concept
,	O
the	O
full	O
features	O
of	O
the	O
TSS	O
are	O
not	O
used	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
many	O
operating	B-General_Concept
systems	I-General_Concept
use	O
both	O
hardware	O
and	O
software	O
to	O
create	O
a	O
multitasking	B-Operating_System
system	O
.	O
</s>
<s>
Operating	B-General_Concept
systems	I-General_Concept
like	O
OS/2	B-Application
1.x	O
try	O
to	O
switch	O
the	O
processor	O
between	O
protected	O
and	O
real	B-Application
modes	I-Application
.	O
</s>
<s>
This	O
is	O
both	O
slow	O
and	O
unsafe	O
,	O
because	O
a	O
real	B-Application
mode	I-Application
program	O
can	O
easily	O
crash	B-General_Concept
a	O
computer	O
.	O
</s>
<s>
OS/2	B-Application
1.x	O
defines	O
restrictive	O
programming	O
rules	O
allowing	O
a	O
Family	B-Application
API	I-Application
or	O
bound	O
program	O
to	O
run	O
in	O
either	O
real	O
or	O
protected	B-Application
mode	I-Application
.	O
</s>
<s>
Some	O
early	O
Unix	B-Application
operating	I-Application
systems	I-Application
,	O
OS/21.x	O
,	O
and	O
Windows	O
used	O
this	O
mode	O
.	O
</s>
<s>
Windows	O
3.0	O
was	O
able	O
to	O
run	O
real	B-Application
mode	I-Application
programs	O
in	O
16-bit	O
protected	B-Application
mode	I-Application
;	O
when	O
switching	O
to	O
protected	B-Application
mode	I-Application
,	O
it	O
decided	O
to	O
preserve	O
the	O
single	O
privilege	O
level	O
model	O
that	O
was	O
used	O
in	O
real	B-Application
mode	I-Application
,	O
which	O
is	O
why	O
Windows	B-Application
applications	I-Application
and	O
DLLs	O
can	O
hook	O
interrupts	B-Application
and	O
do	O
direct	O
hardware	O
access	O
.	O
</s>
<s>
If	O
a	O
Windows	O
1.x	O
or	O
2.x	O
program	O
is	O
written	O
properly	O
and	O
avoids	O
segment	B-General_Concept
arithmetic	O
,	O
it	O
will	O
run	O
the	O
same	O
way	O
in	O
both	O
real	O
and	O
protected	B-Application
modes	I-Application
.	O
</s>
<s>
Windows	O
programs	O
generally	O
avoid	O
segment	B-General_Concept
arithmetic	O
because	O
Windows	O
implements	O
a	O
software	O
virtual	B-Architecture
memory	I-Architecture
scheme	O
,	O
moving	O
program	O
code	O
and	O
data	O
in	O
memory	B-General_Concept
when	O
programs	O
are	O
not	O
running	O
,	O
so	O
manipulating	O
absolute	O
addresses	O
is	O
dangerous	O
;	O
programs	O
should	O
only	O
keep	O
handles	O
to	O
memory	B-General_Concept
blocks	O
when	O
not	O
running	O
.	O
</s>
<s>
Starting	O
an	O
old	O
program	O
while	O
Windows3.0	O
is	O
running	O
in	O
protected	B-Application
mode	I-Application
triggers	O
a	O
warning	O
dialog	O
,	O
suggesting	O
to	O
either	O
run	O
Windows	O
in	O
real	B-Application
mode	I-Application
or	O
to	O
obtain	O
an	O
updated	O
version	O
of	O
the	O
application	O
.	O
</s>
<s>
Updating	O
well-behaved	O
programs	O
using	O
the	O
MARK	O
utility	O
with	O
the	O
MEMORY	B-General_Concept
parameter	O
avoids	O
this	O
dialog	O
.	O
</s>
<s>
It	O
is	O
not	O
possible	O
to	O
have	O
some	O
GUI	O
programs	O
running	O
in	O
16-bit	O
protected	B-Application
mode	I-Application
and	O
other	O
GUI	O
programs	O
running	O
in	O
real	B-Application
mode	I-Application
.	O
</s>
<s>
In	O
Windows	O
3.1	O
,	O
real	B-Application
mode	I-Application
was	O
no	O
longer	O
supported	O
and	O
could	O
not	O
be	O
accessed	O
.	O
</s>
<s>
In	O
modern	O
32-bit	O
operating	B-General_Concept
systems	I-General_Concept
,	O
virtual	B-Application
8086	I-Application
mode	I-Application
is	O
still	O
used	O
for	O
running	O
applications	O
,	O
e.g.	O
</s>
<s>
DPMI	O
compatible	O
DOS	B-Device
extender	I-Device
programs	O
(	O
through	O
virtual	O
DOS	B-Device
machines	O
)	O
or	O
Windows3.x	O
applications	O
(	O
through	O
the	O
Windows	B-Application
on	I-Application
Windows	I-Application
subsystem	O
)	O
and	O
certain	O
classes	O
of	O
device	B-Application
drivers	I-Application
(	O
e.g.	O
</s>
<s>
for	O
changing	O
the	O
screen-resolution	O
using	O
BIOS	B-Operating_System
functionality	O
)	O
in	O
OS/2	B-Application
2.0	O
(	O
and	O
later	O
OS/2	B-Application
)	O
and	O
32-bit	B-Application
Windows	I-Application
NT	O
,	O
all	O
under	O
control	O
of	O
a	O
32-bit	O
kernel	O
.	O
</s>
<s>
However	O
,	O
64-bit	O
operating	B-General_Concept
systems	I-General_Concept
(	O
which	O
run	O
in	O
long	B-Application
mode	I-Application
)	O
no	O
longer	O
use	O
this	O
,	O
since	O
virtual	B-Application
8086	I-Application
mode	I-Application
has	O
been	O
removed	O
from	O
long	B-Application
mode	I-Application
.	O
</s>
