Virtual Memory

 

Example 1

Therefore we have the following:

This means that our virtual addresses are 8 bits (3 bits to choose the page, 5 bits to locate the word within the page) and our physical addresses are 7 bits (2 bits to choose the frame, 5 bits to locate the word within the page).

Suppose the processor generates the address 7216 = 0111 00102. The first 3 bits give the page number (316) and the last 5 bits give the offset within the page (1216). To get the physical address, use the page number as the subscript in the page table. Page table entry 3 specifies that the page is in RAM and that it is in frame 0. Therefore the physical address is 001 0010 (frame 0, offset 10010).

Suppose the processor generates the address BA16 = 1011 10102. The first 3 bits give the page number (516) and the last 5 bits give the offset within the page (1A16). To get the physical address, use the page number as the subscript in the page table. Page table entry 5 specifies that the page is not in RAM. It needs to be loaded into a page frame. Suppose it is loaded into frame 2, which means that page 0, which is currently in frame 2 is swapped out to disk. Then the physical address is 101 1010 (frame 2, offset 11010). Also the page table must be updated so that entry 0 has a valid bit of 0 (page 0 is now on disk) and entry 5 specifies that the page is in frame 2 and the valid bit is set to 1.

Example 2

Therefore we have the following:

This means that our virtual addresses are 13 bits (3 bits to choose the page, 10 bits to locate the word within the page) and our physical addresses are 12 bits (2 bits to choose the frame, 10 bits to locate the word within the page).

Suppose the processor generates virtual address 155316 = 101 01 0101 00112. The first 3 bits give the page number (516) and the last 10 bits give the offset within the page (15316). To get the physical address, use the page number as the subscript in the page table. Page table entry 5 specifies that the page is in RAM and that it is in frame 1. Therefore the physical address is 01 01 0101 0011 (frame 1, offset 01 0101 0011).

Suppose the processor generates virtual address 80216 = 010 00 0000 00102. The first 3 bits give the page number (216) and the last 10 bits give the offset within the page (216). To get the physical address, use the page number as the subscript in the page table. Page table entry 2 specifies that the page is in RAM and that it is in frame 0. Therefore the physical address is 00 00 0000 0010 (frame 0, offset 00 0000 0010).

Suppose the processor generates virtual address 100416 = 100 00 0000 01002. The first 3 bits give the page number (416) and the last 10 bits give the offset within the page (416). To get the physical address, use the page number as the subscript in the page table. Page table entry 4 specifies that the page is not in RAM, since the valid bit is 0. This results in a page fault.



Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2013