Memory Management-Part3
Memory Management-Part3
Part -3
Prachi Pandey
C-DAC Bangalore
[email protected]
3. Read the desired page into the (newly) free frame; change the
page and frame tables
4. Restart the user process
• Main objective of a good replacement algorithm is to achieve a low
page fault rate
Terminologies
• The string of memory references is called Reference String
0 0 0 0 4 4
0 2 1 6 4 0 0
2 2 2 2
1 1 1 1
6 6 6
M M M M M M
1 0 4 3 4 1 4 2 2 1 2
4
0 0 0
0 0
0
3 3 3
1 3
1
1 1 1
6 6
6
H M M M H
H
• Reference string:
701203042303120
f2 0 0 0 0 3 3 3 2 2 2 2 1 1 1
f1 7 7 7 2 2 2 2 4 4 4 0 0 0 0 0
MMMMH M M M MM M H M M H
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
• 3 frames:
• 4 frames:
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
3 3 3 2 2 2 2 2 4 4
2 2 2 1 1 1 1 1 3 3 3
1 1 1 4 4 4 5 5 5 5 5 5
MMMM M M M H H M M H
4 4 4 4 4 4 3 3 3
3 3 3 3 3 3 2 2 2 2
2 2 2 2 2 2 1 1 1 1 1
1 1 1 1 1 1 5 5 5 5 4 5
M M M M H H M M M M M M
First-In-First-Out (FIFO) Algorithm
• Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
• 3 frames (3 pages can be in memory 1 1 4 5
at a time per process):
2 2 1 3 9 page faults
3 3 2 4
• 4 frames: 1 1 5 4
2 2 1 5 10 page faults
3 3 2
4 4 3
0 0 0 0 4 4
0 2 1 6 4 0 0
2 2 2 2
1 1 1 1
6 6 6
M M M M M M
1 0 4 3 4 1 4 2 2 1 2
4
0 0 0
0 0
0
1 1 1
1 1
1
3 3 3
6 3
6
H M H M H
H
Example LRU Algorithm
Reference string:
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
• 4 frames
Optimal Page Replacement
• Basic idea
• replace the page that will not be referenced for
the longest time
• This gives the lowest possible fault rate
• Impossible to implement
• Does provide a good measure for other
techniques
Reference string: 0, 2, 1, 6, 4, 0, 1, 0, 3, 1, 2, 1
0 0 0 0 0 0
0 2 1 6 4 0 2
2 2 2 2
1 1 1 1
6 4 4
M M M M M H
1 0 0 3 3 1 3 2 3 1 3
0
2 2 2
2 2
2
1 1 1
1 1
1
4 4 4
4 4
4
H M H H H
H
Questions ??