Determine the number of page faults when references to pages occur in the…
2016
Determine the number of page faults when references to pages occur in the following order: 1, 2, 4, 5, 2, 1, 2, 4 Assume that the main memory can accommodate 3 pages and the main memory already has the pages 1 and 2, with page one having brought earlier than page 2. (LRU page replacement algorithm is used)
- A.
3
- B.
5
- C.
4
- D.
None of these
Attempted by 68 students.
Show answer & explanation
Correct answer: C
We simulate the LRU page replacement algorithm with 3 frames.
Initial state: Memory contains pages 1 and 2. Page 1 is older than Page 2. One frame is empty.
Reference 1: Hit (already in memory). Memory state updates to [2, 1].
Reference 2: Hit (already in memory). Memory state updates to [1, 2].
Reference 4: Page Fault (empty frame available). Memory state becomes [1, 2, 4]. Total faults: 1.
Reference 5: Page Fault (replace LRU page 1). Memory state becomes [2, 4, 5]. Total faults: 2.
Reference 2: Hit (already in memory). Memory state updates to [4, 5, 2].
Reference 1: Page Fault (replace LRU page 4). Memory state becomes [5, 2, 1]. Total faults: 3.
Reference 2: Hit (already in memory). Memory state updates to [5, 1, 2].
Reference 4: Page Fault (replace LRU page 5). Memory state becomes [1, 2, 4]. Total faults: 4.
Total page faults: 4.
A video solution is available for this question — log in and enroll to watch it.