Consider the following page reference string find LRU and Optimal algorithm note that initially all frames are empty.

 In this post we are discussing Consider the following page reference string [ 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1,2,0,1,7,0,1 ] Assuming there are 3 memory frames, how many page faults would occur in case of assuming there are 3 memory frames, i)LRU ii)Optimal algorithm note that initially all frames are empty.

Given page reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1

Number of memory frames (frames): 3

i) LRU Algorithm: In the LRU algorithm, we replace the page that has not been used for the longest time.

String70120304230321201701
Frame -177722224440001111111
Frame -20000000033333300000
Frame -3111333222222222777
Fault (F) / Hit (H)FFFFHFHFFFFHHFHFHFHH
LRU Algorithm

The total number of page faults using the LRU algorithm is 12.

The total number of page Hits using the LRU algorithm is 8.

ii) Optimal Algorithm: In the Optimal algorithm, we replace the page that will not be used for the longest time in the future. This algorithm requires looking ahead in the page reference string to make replacement decisions.

String70120304230321201701
Frame -177722222222222222777
Frame -20000004440000000000
Frame -3111333333331111111
Fault (F) / Hit (H)FFFFHFHFHHFHHFHHHFHH
Optimal Algorithm

The total number of page faults using the Optimal algorithm is 9.

The total number of page Hits using the Optimal algorithm is 11.

Leave a Reply

Your email address will not be published. Required fields are marked *