The OS correctly predicts only up to next page references (including the current page) at the time of allocating a frame to a page.
A process accesses the pages in the following order of page numbers:
If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is __________. (Answer in integer)
View worked solution
Answer: 6:6
In the modified optimal page replacement algorithm, when a page fault occurs at time step , the OS only has visibility of the next page references (from index to , inclusive). It replaces the page in the memory frames whose next reference in this lookahead window is furthest in the future. If a page in the frames is not referenced in this window, its next reference is treated as being at infinity.
Let the reference string be indexed from to :
Let's trace the execution with initially empty frames:
- (Page 1): Page fault. Frames:
- (Page 3): Page fault. Frames:
- (Page 2): Page fault. Frames:
- (Page 4): Page fault.
- Lookahead window (indices to ):
- Next references of current pages: is at , is at , and is at .
- Since is furthest, we replace with .
- Frames:
- (Page 2): Hit. Frames:
- (Page 3): Hit. Frames:
- (Page 1): Page fault.
- Lookahead window (indices to ):
- Next references of current pages: is at , is at , and is at .
- Since is furthest, we replace with .
- Frames:
- (Page 2): Hit. Frames:
- (Page 4): Hit. Frames:
- (Page 3): Page fault.
- Lookahead window (indices to ):
- Next references of current pages: is at , is at , and is not in the window (infinity).
- Since is not in the window, we replace with .
- Frames:
- (Page 1): Hit. Frames:
- (Page 4): Hit. Frames:
The total number of page faults that occur during execution is 6.
Free practice · Your answers on this page are not saved.
