In: Computer Science
Consider the following page reference string: 1,2,3,5,4,2,1,5,4,2,6,3,1,2,6,3,1,2,4,7,5,4,3,5 How many page faults would occur for replaement by LRU, FIFO, optimal, for four frames? All frames are initially empty and first unique page reference causes a page fault. Draw the frame for each page reference.
in fifo
string | 1 | 2 | 3 | 5 | 4 | 2 | 1 | 5 | 4 | 2 | 6 | 3 | 1 | 2 | 6 | 3 | 1 | 2 | 4 | 7 | 5 | 4 | 3 | 5 |
frame 1 | 1 | 1 | 1 | 1 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
frame 2 | 2 | 2 | 2 | 2 | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 4 | 4 | 4 | 4 | |
frame 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 7 | 7 | 7 | 7 | 7 | ||
frame 4 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 5 | 5 | 5 | 5 | |||
page fault | y | y | y | y | y | n | y | n | y | y | y | y | n | n | n | n | n | n | y | y | y | n | n | n |
total page fault is 11
in lru
string | 1 | 2 | 3 | 5 | 4 | 2 | 1 | 5 | 4 | 2 | 6 | 3 | 1 | 2 | 6 | 3 | 1 | 2 | 4 | 7 | 5 | 4 | 3 | 5 |
frame 1 | 1 | 1 | 1 | 1 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | 5 | 5 | 5 |
frame 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | |
frame 3 | 3 | 3 | 3 | 3 | 1 | 1 | 1 | 1 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 4 | 4 | 4 | 4 | 3 | 3 | ||
frame 4 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 7 | 7 | 7 | 7 | 7 | |||
page fault | y | y | y | y | y | n | y | n | n | n | y | y | y | n | n | n | n | n | y | y | y | n | y | n |
total page fault is 13+-
in optimal
string | 1 | 2 | 3 | 5 | 4 | 2 | 1 | 5 | 4 | 2 | 6 | 3 | 1 | 2 | 6 | 3 | 1 | 2 | 4 | 7 | 5 | 4 | 3 | 5 |
frame 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 4 | 4 | 4 | 4 |
frame 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 7 | 7 | 7 | 7 | 7 | |
frame 3 | 3 | 3 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | ||
frame 4 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 5 | 5 | 5 | 5 | |||
page fault | y | y | y | y | y | n | n | n | n | n | y | y | n | n | n | n | n | n | y | y | y | n | n | n |
total page fault is 10