Suppose for a process 𝑃, reference to pages in order are 1,2,4,5,2,1,2,4.…
2018
Suppose for a process 𝑃, reference to pages in order are 1,2,4,5,2,1,2,4. Assume that main memory can accomodate 3 pages and the main memory has already 1 and 2 in the order 1 – first, 2 – second. At this moment, assume FIFO Page Replacement Algorithm is used then the number of page faults that occur to complete the execution of process 𝑃 is
- A.
4
- B.
3
- C.
5
- D.
6
Attempted by 152 students.
Show answer & explanation
Correct answer: C
Solution: Simulate the FIFO algorithm with three frames. Initial frames: page 1 (oldest), page 2 (second), and one empty frame.
Reference 1: Hit (page 1 is already in memory). Frames: [1, 2, empty]. Faults so far: 0.
Reference 2: Hit (page 2 is in memory). Frames unchanged: [1, 2, empty]. Faults so far: 0.
Reference 4: Miss. Load into the empty frame. Frames: [1, 2, 4]. Faults so far: 1.
Reference 5: Miss. FIFO evicts the oldest loaded page (page 1). Replace it with 5. Frames: [5, 2, 4]. Faults so far: 2.
Reference 2: Hit (page 2 is present). Frames unchanged: [5, 2, 4]. Faults so far: 2.
Reference 1: Miss. FIFO evicts the oldest remaining page (page 2). Replace it with 1. Frames: [5, 1, 4]. Faults so far: 3.
Reference 2: Miss. FIFO evicts the oldest page (page 4). Replace it with 2. Frames: [5, 1, 2]. Faults so far: 4.
Reference 4: Miss. FIFO evicts the oldest page (page 5). Replace it with 4. Frames: [4, 1, 2]. Faults so far: 5.
Total page faults: 5
A video solution is available for this question — log in and enroll to watch it.