2. If the valid bit = 1, the page is in memory.
a. Replace the virtual page number with the actual frame number.
b. Access data at offset in physical page frame by adding the offset to
the frame number for the given virtual page.
Please note that if a process has free frames in main memory when a page fault
occurs, the newly retrieved page can be placed in any of those free frames. However,
if the memory allocated to the process is full, a victim page must be
selected. The replacement algorithms used to select a victim are quite similar to
those used in cache. FIFO, Random, and LRU are all potential replacement algorithms
for selecting a victim page. (For more information on replacement algorithms,
see the references at the end of this chapter.)
Let’s look at an example. Suppose that we have a virtual address space of 28
words for a given process (this means the program generates addresses in the
range 0 to 25510 which is 00 to FF16), and physical memory of 4 page frames (no
cache). Assume also that pages are 32 words in length. Virtual addresses contain
8 bits, and physical addresses contain 7 bits (4 frames of 32 words each is 128
words, or 27). Suppose, also, that some pages from the process have been brought
into main memory. Figure 6.11 illustrates the current state of the system.
Each virtual address has 8 bits and is divided into 2 fields: the page field has
3 bits, indicating there are 23 pages of virtual memory
28
25
= 23. Each page is
25 = 32 words in length, so we need 5 bits for the page offset. Therefore, an 8-bit
virtual address has the format shown in Figure 6.12.
Suppose the system now generates the virtual address 1310 = 0D16 =
000011012. Dividing the binary address into the page and offset fields (see Figure