format and is determined by the memory manager.
For example, for an unmapped
page that must be allocated and zeroed before it may be used, that fact is noted in
the page-table entry.
AVaiLable to the OS
Page Attribute Table
Page Cache Disable
A page-table entry (PTE) for a mapped page on the Intel x86 and
AMD x64 architectures.
Two important bits in the page-table entry are updated by the hardware direct-
These are the access (A) and dirty (D) bits.
These bits keep track of when a
particular page mapping has been used to access the page and whether that access
could have modified the page by writing it.
This really helps the performance of
the system because the memory manager can use the access bit to implement the
) style of paging.
The LRU principle says that pages
which have not been used the longest are the least likely to be used again soon.
The access bit allows the memory manager to determine that a page has been ac-
cessed. The dirty bit lets the memory manager know that a page may have been
modified, or more significantly, that a page has
been modified. If a page has
not been modified since being read from disk, the memory manager does not have
to write the contents of the page to disk before using it for something else.
Both the x86 and x64 use a 64-bit page-table entry, as shown in Fig. 11-31.
Each page fault can be considered as being in one of five categories:
The page referenced is not committed.
Access to a page has been attempted in violation of the permissions.
A shared copy-on-write page was about to be modified.
The stack needs to grow.
The page referenced is committed but not currently mapped in.
The first and second cases are due to programming errors.
If a program at-
tempts to use an address which is not supposed to have a valid mapping, or at-
tempts an invalid operation (like attempting to write a read-only page) this is called
CASE STUDY 2: WINDOWS 8
and usually results in termination of the process.
tions are often the result of bad pointers, including accessing memory that was
freed and unmapped from the process.
The third case has the same symptoms as the second one (an attempt to write
to a read-only page), but the treatment is different. Because the page has been
, the memory manager does not report an access violation,
but instead makes a private copy of the page for the current process and then re-
turns control to the thread that attempted to write the page.
The thread will retry
the write, which will now complete without causing a fault.
The fourth case occurs when a thread pushes a value onto its stack and crosses
onto a page which has not been allocated yet.
The memory manager is program-
med to recognize this as a special case.
As long as there is still room in the virtual
pages reserved for the stack, the memory manager will supply a new physical page,
zero it, and map it into the process.
When the thread resumes running, it will retry
the access and succeed this time around.
Finally, the fifth case is a normal page fault. However, it has several subcases.
If the page is mapped by a file, the memory manager must search its data struc-
tures, such as the prototype page table associated with the section object to be sure
that there is not already a copy in memory.
If there is, say in another process or on
the standby or modified page lists, it will just share it—perhaps marking it as copy-
on-write if changes are not supposed to be shared.
If there is not already a copy,
the memory manager will allocate a free physical page and arrange for the file
page to be copied in from disk, unless another the page is already transitioning in
from disk, in which case it is only necessary to wait for the transition to complete.
When the memory manager can satisfy a page fault by finding the needed page
in memory rather than reading it in from disk, the fault is classified as a
If the copy from disk is needed, it is a
Soft faults are much cheaper,
and have little impact on application performance compared to hard faults. Soft
faults can occur because a shared page has already been mapped into another proc-
ess, or only a new zero page is needed, or the needed page was trimmed from the
process’ working set but is being requested again before it has had a chance to be
reused. Soft faults can also occur because pages have been compressed to ef-
fectively increase the size of physical memory.
For most configurations of CPU,
memory, and I/O in current systems it is more efficient to use compression rather
than incur the I/O expense (performance and energy) required to read a page from
When a physical page is no longer mapped by the page table in any process it
goes onto one of three lists: free, modified, or standby.
Pages that will never be
needed again, such as stack pages of a terminating process, are freed immediately.
Pages that may be faulted again go to either the modified list or the standby list,
depending on whether or not the dirty bit was set for any of the page-table entries
that mapped the page since it was last read from disk.
Pages in the modified list
will be eventually written to disk, then moved to the standby list.