CS 3733 Operating Systems
Lecture 11 [10/1/97]: Page Replacement Policies
Reading: Tanenbaum Section 3.4
Virtual Memory
- Each page table entry has a bit indicating whether the page
actually occupies a page frame.
- Initially when the process is allocated resources, the page
table is set up with all (or most) of the entries marked invalid.
- When a particular page is referenced, the hardware checks to see
if the page operation is permitted (e.g. writable) and if not,
the program aborts.
- When a particular page is referenced, the hardware checks to see
if the page table entry is valid. If it is, everything is as before.
- If an invalid page is referenced, a page fault trap will occur and
the following must be done:
- Remove the process from the CPU. When restarted, the instruction
which caused the page fault will be reexecuted.
(Be careful to undo operations such as MOV -(R2), (R3)+
.)
- Find a free frame from the free frame list and update this list.
- Schedule a disk operation to read page into frame.
- Update the page table.
- If the process never attempts to access a particular page of memory,
it is never brought in.
-
PSECTS
in VAX assembly language are defined on page boundaries.
You can put restrictions such as noexc
or nowrt
on pages and keep
the protection information in the page table.
- The major components of page fault service are:
- Service the page fault interrupt.
- Swap in the page.
- Restart the process.
Page Replacement
When a new page needs to
be brought in, there will not always be an empty frame. Which frame
should be replaced?
- FIFO - first-in-first-out
- This is very simple to implement - just keep a FIFO queue and
add an entry to the back when a page is placed in a frame.
- Unfortunately the most heavily used pages are often the ones
brought in first.
- Note that the FIFO queue gets updated only when there is a page
fault, not on each reference. This implies that it is possible
to generate reference strings which do worse when there are more
frames.
- Example:
Calculate the number of page faults obtained for the following reference
string:
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
- When the memory has 3 frames
- When the memory has 4 frames
Revision Date: 10/6/97