Page Replacement Algorithms 2
Page Replacement Algorithms 2
Page Replacement Algorithms 2
1
FIFO
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 0 1 2 2 3 0 4 2 3 0 0 0 1 2 2 2 7 0 1
7 0 1 1 2 3 0 4 2 3 3 3 0 1 1 1 2 7 0
7 0 0 1 2 3 0 4 2 2 2 3 0 0 0 1 2 7
1 2 3 4 1 2 5 1 2 3 4 5
1 2 3 4 1 2 5 5 5 3 4 4
1 2 3 4 1 2 2 2 5 3 3
1 2 3 4 1 1 1 2 5 5
1 2 3 4 1 2 5 1 2 3 4 5
1 2 3 4 4 4 5 1 2 3 4 5 Belady's
1 2 3 3 3 4 5 1 2 3 4 anomaly:
1 2 2 2 3 4 5 1 2 3 more frames
1 1 1 2 3 4 5 1 2 can be worse
2-5
Optimal
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 7 7 7
0 0 0 0 0 0 4 4 4 0 0 0 0 0 0 0 0 0 0
1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1
1 2 3 4 1 2 5 1 2 3 4 5
1 1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 3 4 4
3 4 4 4 5 5 5 5 5 5
1 2 3 4 1 2 5 1 2 3 4 5
1 1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 But how do
3 3 3 3 3 3 3 3 4 4 you predict
4 4 4 5 5 5 5 5 5 the future?
6-7
LRU
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
70 71 72 20 21 22 23 40 41 42 00 01 02 10 11 12 10 11 12 10
00 01 02 00 01 00 01 02 30 31 30 31 32 33 00 01 02 00 01
10 11 12 30 31 32 20 21 22 23 20 21 20 21 22 70 71 72
1 2 3 4 1 2 5 1 2 3 4 5
10 11 12 40 41 42 50 51 52 30 31 32
20 21 22 10 11 12 10 11 12 40 41
30 31 32 20 21 22 20 21 22 50 Searching all
times is
1 2 3 4 1 2 5 1 2 3 4 5 expensive on
10 11 12 13 10 11 12 10 11 12 13 50 fault; keeping
20 21 22 23 20 21 22 20 21 22 23 a sorted list is
30 31 32 33 50 51 52 53 40 41 expensive on
40 41 42 43 44 45 30 31 32 access
8-9
Second Chance
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
71 71 71 21 21 21 21 41 41 41 40 31 31 30 30 01 01 00 01 01
01 01 00 01 00 01 00 21 21 20 20 21 11 11 11 11 71 71 71
11 10 10 31 31 30 30 31 01 01 01 00 21 21 21 20 20 11
1 2 3 4 1 2 5 1 2 3 4 5
11 11 11 41 41 41 51 51 51 50 50 51
21 21 20 11 11 10 11 11 31 31 31
31 30 30 21 20 20 21 20 41 41
1 2 3 4 1 2 5 1 2 3 4 5
11 11 11 11 11 11 51 51 51 51 41 41
21 21 21 21 21 20 11 11 11 10 51
31 31 31 31 30 30 21 21 20 20
41 41 41 40 40 40 31 30 30
10
Second Chance
11
Enhanced Second Chance
12
Allocating Frames
13
Thrashing
fork();
}
}
14
Thrashing
15
Measuring Working Set
16
Interaction with I/O
17