<s>
In	O
computing	O
,	O
a	O
page	B-General_Concept
fault	I-General_Concept
(	O
sometimes	O
called	O
PF	O
or	O
hard	B-General_Concept
fault	I-General_Concept
)	O
is	O
an	O
exception	B-General_Concept
that	O
the	O
memory	B-General_Concept
management	I-General_Concept
unit	I-General_Concept
(	O
MMU	O
)	O
raises	O
when	O
a	O
process	B-Operating_System
accesses	O
a	O
memory	B-General_Concept
page	I-General_Concept
without	O
proper	O
preparations	O
.	O
</s>
<s>
Accessing	O
the	O
page	O
requires	O
a	O
mapping	O
to	O
be	O
added	O
to	O
the	O
process	B-Operating_System
's	O
virtual	B-General_Concept
address	I-General_Concept
space	I-General_Concept
.	O
</s>
<s>
Besides	O
,	O
the	O
actual	O
page	O
contents	O
may	O
need	O
to	O
be	O
loaded	O
from	O
a	O
backing	O
store	O
,	O
such	O
as	O
a	O
disk	B-Device
.	O
</s>
<s>
The	O
MMU	O
detects	O
the	O
page	B-General_Concept
fault	I-General_Concept
,	O
but	O
the	O
operating	B-General_Concept
system	I-General_Concept
's	O
kernel	B-Operating_System
handles	O
the	O
exception	B-General_Concept
by	O
making	O
the	O
required	O
page	O
accessible	O
in	O
the	O
physical	O
memory	O
or	O
denying	O
an	O
illegal	O
memory	O
access	O
.	O
</s>
<s>
Valid	O
page	B-General_Concept
faults	I-General_Concept
are	O
common	O
and	O
necessary	O
to	O
increase	O
the	O
amount	O
of	O
memory	O
available	O
to	O
programs	O
in	O
any	O
operating	B-General_Concept
system	I-General_Concept
that	O
uses	O
virtual	B-Architecture
memory	I-Architecture
,	O
such	O
as	O
Windows	O
,	O
macOS	B-Application
,	O
and	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
If	O
the	O
page	O
is	O
loaded	O
in	O
memory	O
at	O
the	O
time	O
the	O
fault	O
is	O
generated	O
,	O
but	O
is	O
not	O
marked	O
in	O
the	O
memory	B-General_Concept
management	I-General_Concept
unit	I-General_Concept
as	O
being	O
loaded	O
in	O
memory	O
,	O
then	O
it	O
is	O
called	O
a	O
minor	O
or	O
soft	O
page	B-General_Concept
fault	I-General_Concept
.	O
</s>
<s>
The	O
page	B-General_Concept
fault	I-General_Concept
handler	O
in	O
the	O
operating	B-General_Concept
system	I-General_Concept
merely	O
needs	O
to	O
make	O
the	O
entry	O
for	O
that	O
page	O
in	O
the	O
memory	B-General_Concept
management	I-General_Concept
unit	I-General_Concept
point	O
to	O
the	O
page	O
in	O
memory	O
and	O
indicate	O
that	O
the	O
page	O
is	O
loaded	O
in	O
memory	O
;	O
it	O
does	O
not	O
need	O
to	O
read	O
the	O
page	O
into	O
memory	O
.	O
</s>
<s>
This	O
could	O
happen	O
if	O
the	O
memory	B-Operating_System
is	I-Operating_System
shared	I-Operating_System
by	O
different	O
programs	O
and	O
the	O
page	O
is	O
already	O
brought	O
into	O
memory	O
for	O
other	O
programs	O
.	O
</s>
<s>
The	O
page	O
could	O
also	O
have	O
been	O
removed	O
from	O
the	O
working	B-General_Concept
set	I-General_Concept
of	O
a	O
process	B-Operating_System
,	O
but	O
not	O
yet	O
written	O
to	O
disk	B-Device
or	O
erased	O
,	O
such	O
as	O
in	O
operating	B-General_Concept
systems	I-General_Concept
that	O
use	O
Secondary	O
Page	O
Caching	O
.	O
</s>
<s>
For	O
example	O
,	O
HP	O
OpenVMS	O
may	O
remove	O
a	O
page	O
that	O
does	O
not	O
need	O
to	O
be	O
written	O
to	O
disk	B-Device
(	O
if	O
it	O
has	O
remained	O
unchanged	O
since	O
it	O
was	O
last	O
read	O
from	O
disk	B-Device
,	O
for	O
example	O
)	O
and	O
place	O
it	O
on	O
a	O
Free	O
Page	O
List	O
if	O
the	O
working	B-General_Concept
set	I-General_Concept
is	O
deemed	O
too	O
large	O
.	O
</s>
<s>
However	O
,	O
the	O
page	O
contents	O
are	O
not	O
overwritten	O
until	O
the	O
page	O
is	O
assigned	O
elsewhere	O
,	O
meaning	O
it	O
is	O
still	O
available	O
if	O
it	O
is	O
referenced	O
by	O
the	O
original	O
process	B-Operating_System
before	O
being	O
allocated	O
.	O
</s>
<s>
Since	O
these	O
faults	O
do	O
not	O
involve	O
disk	B-Device
latency	O
,	O
they	O
are	O
faster	O
and	O
less	O
expensive	O
than	O
major	O
page	B-General_Concept
faults	I-General_Concept
.	O
</s>
<s>
This	O
is	O
the	O
mechanism	O
used	O
by	O
an	O
operating	B-General_Concept
system	I-General_Concept
to	O
increase	O
the	O
amount	O
of	O
program	O
memory	O
available	O
on	O
demand	O
.	O
</s>
<s>
The	O
operating	B-General_Concept
system	I-General_Concept
delays	O
loading	O
parts	O
of	O
the	O
program	O
from	O
disk	B-Device
until	O
the	O
program	O
attempts	O
to	O
use	O
it	O
and	O
the	O
page	B-General_Concept
fault	I-General_Concept
is	O
generated	O
.	O
</s>
<s>
If	O
the	O
page	O
is	O
not	O
loaded	O
in	O
memory	O
at	O
the	O
time	O
of	O
the	O
fault	O
,	O
then	O
it	O
is	O
called	O
a	O
major	O
or	O
hard	O
page	B-General_Concept
fault	I-General_Concept
.	O
</s>
<s>
The	O
page	B-General_Concept
fault	I-General_Concept
handler	O
in	O
the	O
OS	O
needs	O
to	O
find	O
a	O
free	O
location	O
:	O
either	O
a	O
free	O
page	O
in	O
memory	O
,	O
or	O
a	O
non-free	O
page	O
in	O
memory	O
.	O
</s>
<s>
This	O
latter	O
might	O
be	O
used	O
by	O
another	O
process	B-Operating_System
,	O
in	O
which	O
case	O
the	O
OS	O
needs	O
to	O
write	O
out	O
the	O
data	O
in	O
that	O
page	O
(	O
if	O
it	O
has	O
not	O
been	O
written	O
out	O
since	O
it	O
was	O
last	O
modified	O
)	O
and	O
mark	O
that	O
page	O
as	O
not	O
being	O
loaded	O
in	O
memory	O
in	O
its	O
process	B-Operating_System
page	B-General_Concept
table	I-General_Concept
.	O
</s>
<s>
Once	O
the	O
space	O
has	O
been	O
made	O
available	O
,	O
the	O
OS	O
can	O
read	O
the	O
data	O
for	O
the	O
new	O
page	O
into	O
memory	O
,	O
add	O
an	O
entry	O
to	O
its	O
location	O
in	O
the	O
memory	B-General_Concept
management	I-General_Concept
unit	I-General_Concept
,	O
and	O
indicate	O
that	O
the	O
page	O
is	O
loaded	O
.	O
</s>
<s>
If	O
a	O
page	B-General_Concept
fault	I-General_Concept
occurs	O
for	O
a	O
reference	O
to	O
an	O
address	O
that	O
is	O
not	O
part	O
of	O
the	O
virtual	B-General_Concept
address	I-General_Concept
space	I-General_Concept
,	O
meaning	O
there	O
cannot	O
be	O
a	O
page	O
in	O
memory	O
corresponding	O
to	O
it	O
,	O
then	O
it	O
is	O
called	O
an	O
invalid	O
page	B-General_Concept
fault	I-General_Concept
.	O
</s>
<s>
The	O
page	B-General_Concept
fault	I-General_Concept
handler	O
in	O
the	O
operating	B-General_Concept
system	I-General_Concept
will	O
then	O
generally	O
pass	O
a	O
segmentation	B-Error_Name
fault	I-Error_Name
to	O
the	O
offending	O
process	B-Operating_System
,	O
indicating	O
that	O
the	O
access	O
was	O
invalid	O
;	O
this	O
usually	O
results	O
in	O
abnormal	B-Application
termination	I-Application
of	O
the	O
code	O
that	O
made	O
the	O
invalid	O
reference	O
.	O
</s>
<s>
A	O
null	O
pointer	O
is	O
usually	O
represented	O
as	O
a	O
pointer	O
to	O
address	O
0	O
in	O
the	O
address	B-General_Concept
space	I-General_Concept
;	O
many	O
operating	B-General_Concept
systems	I-General_Concept
set	O
up	O
the	O
MMU	O
to	O
indicate	O
that	O
the	O
page	O
that	O
contains	O
that	O
address	O
is	O
not	O
in	O
memory	O
,	O
and	O
do	O
not	O
include	O
that	O
page	O
in	O
the	O
virtual	B-General_Concept
address	I-General_Concept
space	I-General_Concept
,	O
so	O
that	O
attempts	O
to	O
read	O
or	O
write	O
the	O
memory	O
referenced	O
by	O
a	O
null	O
pointer	O
get	O
an	O
invalid	O
page	B-General_Concept
fault	I-General_Concept
.	O
</s>
<s>
Illegal	O
accesses	O
and	O
invalid	O
page	B-General_Concept
faults	I-General_Concept
can	O
result	O
in	O
a	O
segmentation	B-Error_Name
fault	I-Error_Name
or	O
bus	B-General_Concept
error	I-General_Concept
,	O
resulting	O
in	O
an	O
app	O
or	O
OS	O
crash	B-General_Concept
.	O
</s>
<s>
Software	B-Error_Name
bugs	I-Error_Name
are	O
often	O
the	O
causes	O
of	O
these	O
problems	O
,	O
but	O
hardware	O
memory	O
errors	O
,	O
such	O
as	O
those	O
caused	O
by	O
overclocking	B-Application
,	O
may	O
corrupt	O
pointers	O
and	O
cause	O
healthy	O
codes	O
to	O
fail	O
.	O
</s>
<s>
Operating	B-General_Concept
systems	I-General_Concept
provide	O
differing	O
mechanisms	O
for	O
reporting	O
page	B-General_Concept
fault	I-General_Concept
errors	O
.	O
</s>
<s>
Microsoft	B-Application
Windows	I-Application
uses	O
structured	B-Library
exception	I-Library
handling	I-Library
to	O
report	O
invalid	O
page	B-General_Concept
faults	I-General_Concept
as	O
access	B-Error_Name
violation	I-Error_Name
exceptions	O
.	O
</s>
<s>
UNIX-like	B-Operating_System
systems	I-Operating_System
typically	O
use	O
signals	B-Operating_System
,	O
such	O
as	O
SIGSEGV	B-Error_Name
,	O
to	O
report	O
these	O
error	O
conditions	O
to	O
programs	O
.	O
</s>
<s>
If	O
the	O
program	O
receiving	O
the	O
error	O
does	O
not	O
handle	O
it	O
,	O
the	O
operating	B-General_Concept
system	I-General_Concept
performs	O
a	O
default	O
action	O
,	O
typically	O
involving	O
the	O
termination	O
of	O
the	O
running	O
process	B-Operating_System
that	O
caused	O
the	O
error	O
condition	O
,	O
and	O
notifying	O
the	O
user	O
that	O
the	O
program	O
has	O
malfunctioned	O
.	O
</s>
<s>
Windows	O
often	O
reports	O
such	O
crashes	B-General_Concept
without	O
going	O
to	O
any	O
details	O
.	O
</s>
<s>
An	O
experienced	O
user	O
can	O
retrieve	O
detailed	O
information	O
using	O
WinDbg	B-Application
and	O
the	O
minidump	O
that	O
Windows	O
creates	O
during	O
the	O
crash	B-General_Concept
.	O
</s>
<s>
UNIX-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
report	O
these	O
conditions	O
with	O
such	O
error	O
messages	O
as	O
"	O
segmentation	B-Error_Name
violation	I-Error_Name
"	O
or	O
"	O
bus	B-General_Concept
error	I-General_Concept
"	O
,	O
and	O
may	O
produce	O
a	O
core	B-Error_Name
dump	I-Error_Name
.	O
</s>
<s>
Page	B-General_Concept
faults	I-General_Concept
degrade	O
system	O
performance	O
and	O
can	O
cause	O
thrashing	B-General_Concept
.	O
</s>
<s>
Major	O
page	B-General_Concept
faults	I-General_Concept
on	O
conventional	O
computers	O
using	O
hard	B-Device
disk	I-Device
drives	I-Device
can	O
have	O
a	O
significant	O
impact	O
on	O
their	O
performance	O
,	O
as	O
an	O
average	O
hard	B-Device
disk	I-Device
drive	I-Device
has	O
an	O
average	O
rotational	O
latency	O
of	O
3ms	O
,	O
a	O
seek	O
time	O
of	O
5ms	O
,	O
and	O
a	O
transfer	O
time	O
of	O
0.05ms/page	O
.	O
</s>
<s>
If	O
the	O
memory	O
access	O
time	O
is	O
0.2μs	O
,	O
then	O
the	O
page	B-General_Concept
fault	I-General_Concept
would	O
make	O
the	O
operation	O
about	O
40,000	O
times	O
slower	O
.	O
</s>
<s>
Performance	O
optimization	O
of	O
programs	O
or	O
operating	B-General_Concept
systems	I-General_Concept
often	O
involves	O
reducing	O
the	O
number	O
of	O
page	B-General_Concept
faults	I-General_Concept
.	O
</s>
<s>
Two	O
primary	O
focuses	O
of	O
the	O
optimization	O
are	O
reducing	O
overall	O
memory	O
usage	O
and	O
improving	O
memory	B-General_Concept
locality	I-General_Concept
.	O
</s>
<s>
To	O
reduce	O
the	O
page	B-General_Concept
faults	I-General_Concept
,	O
developers	O
must	O
use	O
an	O
appropriate	O
page	B-General_Concept
replacement	I-General_Concept
algorithm	I-General_Concept
that	O
maximizes	O
the	O
page	O
hits	O
.	O
</s>
<s>
Many	O
have	O
been	O
proposed	O
,	O
such	O
as	O
implementing	O
heuristic	B-Algorithm
algorithms	I-Algorithm
to	O
reduce	O
the	O
incidence	O
of	O
page	B-General_Concept
faults	I-General_Concept
.	O
</s>
<s>
A	O
larger	O
physical	O
memory	O
also	O
reduces	O
page	B-General_Concept
faults	I-General_Concept
.	O
</s>
