Memory Management
Memory Management
Policies
Key Design Policies
•Fetch Policy
Demand
Prepaging
•Replacement Policy
Optimal
Least Recently Used (LRU)
FIFO
Clock
Resident Set Management
Replacement Scope
2
Fetch Policy
• When a page should be brought into main
memory
1. Demand Paging
A page is brought in memory only when referenced
Initially a lot of Page faults would happen
But it will settle down in a while
Later page faults will drop to a very low level
2. Prepaging
Pages other than the one demanded are brought
in memory
3
Replacement Policy
• Selection of a page in memory to be replaced
• When a new page must be brought in
4
Basic Replacement Algorithms
• Optimal
• Least Recently used
• FIFO
5
Optimal
• Select the page for which the time to the next
reference is the longest
• Just like SJF, very difficult to implement
• Assume a memory of 3 frames
• And 5 pages
• Let the reference sequence be
2 3 2 1 5 2 4 5 3 2 5 2
6
Pa
ge
Optimal Fa
F F F u lt
2 3 2 1 5 2 4 5 3 2 5 2
2
4
3
1
5
Select the page for which the time
to the next reference is the longest
7
Least Recently Used (LRU)
• Replace the page that has not been
referenced for the longest time
• Again, difficult to implement
• E.g.
Tag each page with the time of last reference
Should be updated on each instruction/data
reference.
8
Pa
ge
Least Recently Used (LRU) Fa
F F F F ult
2 3 2 1 5 2 4 5 3 2 5 2
2
3
3
5
1
4
2
Select the page Lest Recently Used
9
FIFO
• Treats the page frames as a circular buffer
• Removed in Round-Robin style
• 1. Simplest to implement
• 2. Replaces the page that has been in the
memory longest
• The assumption can be wrong
• Since, some region of code/data remain alive
throughout the programs
10
FIFO Pa
ge
F F F F F F F
2 3 2 1 5 2 4 5 3 2 5 2 au
lt
2
5
3
3
2
5
1
4
2