COMP3891

Virtual Memory

Overview

Paging

On-Demand Paging

Only parts of the program image need to be resident in memory for execution.

Page Fault

Referencing an invalid page triggers a page fault. Two broad categories include:

Thrashing

Thrashing greatly decreases performance and is usually recovered by:

Page Table

Page table is logically an array of frame numbers indexed by page number.

Page Table Entry

|Attribute|Description| |-|-| |Valid Bit|Indicates a valid mapping for the page.| |Modified Bit|Indicates the page may have been modified in memory. Also called dirty bit.| |Reference bit|Indicates the bit has been accessed.| |Protection Bits|Read/write/execute etc.| |Caching Bit|Indicates processor should bypass the cache when accessing memory.|

Two Level Page Table

Page tables grow with address space which can be massive even if only a small portion is used at a time.

Inverted Page Table

Inverted page table contains one entry per frame in real memory and is indexed by frame number.

Hash anchor table keyed by hash of the page number is used to generate possible indexes in the page table. The algorithm to convert from a virtual address is as follows:

Advantages:

Hashed Page Table

Similar to a page table but store frame number as separate field in the table.

Intermediate hash anchor table is removed and we hash directly into the page table.

Advantages:

Drawbacks:

Replacement Policies

Different policies decide which page to throw out when physical memory is used up and a new page needs to be allocated.

Optimal Replacement Policy

FIFO Replacement Policy

Least Recently Used

Clock Page Replacement (Second Chance)

Memory Management Unit

Hardware on the CPU responsible for converting virtual addresses to physical addresses.

Translation Lookaside Buffer

TLB is a cache which holds a (recently used) subset of page table entries.

Exploits principal of locality to greatly reduce the average number of physical memory references per virtual reference.