A process has been allocated page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequence of page references (reference string):
If optimal page replacement policy is used, how many page faults occur for the above reference string?
View worked solution
Answer: A
The Optimal Page Replacement algorithm replaces the page that will not be used for the longest period of time in the future.
We are given empty page frames. Let's trace the execution step-by-step for the reference string: .
| Ref | Frame 1 | Frame 2 | Frame 3 | Fault? | Reason / Action |
|---|---|---|---|---|---|
| 1 | 1 | - | - | Yes (1) | Initial allocation |
| 2 | 1 | 2 | - | Yes (2) | Initial allocation |
| 1 | 1 | 2 | - | No | Page 1 is already in memory (Hit) |
| 3 | 1 | 2 | 3 | Yes (3) | Initial allocation |
| 7 | 1 | 7 | 3 | Yes (4) | Replace 2 (never referenced again) |
| 4 | 1 | 4 | 3 | Yes (5) | Replace 7 (never referenced again) |
| 5 | 1 | 5 | 3 | Yes (6) | Replace 4 (never referenced again) |
| 6 | 1 | 6 | 3 | Yes (7) | Replace 5 (never referenced again) |
| 3 | 1 | 6 | 3 | No | Page 3 is already in memory (Hit) |
| 1 | 1 | 6 | 3 | No | Page 1 is already in memory (Hit) |
Thus, the total number of page faults is .
Free practice · Your answers on this page are not saved.
