When a running program references a page of memory that is not
mapped into its address space the operating system throws a
“page fault” – calling some kernel code to ensure that the page
is loaded and mapped, or if the address referenced is not legal,
that an appropriate error (a seg fault on x86) is signalled and
the program’s execution stopped. If the address is ‘legal’ then
two types of fault exist – a ‘hard’ fault where the missing
memory (eg some code) has to be loaded from disk or a ‘soft’
fault where the missing page is already in memory (typically
because it is in a shared library and being used elsewhere) and
so all that has to happen is for the page to be mapped into the
address space of the executing program. (The above is all a
simplification, but I hope it is clear enough.) Soft faults, as
you might expect are handled much faster than hard faults – as
disk access is generally many orders of magnitude slower than
memory access. Memory management and paging policies are
generally designed to minimi