• edited by
24,676 views
39 39 votes

Consider a main memory with five-page frames and the following sequence of page references: $\text{3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3}$. Which one of the following is true with respect to page replacement policies First In First Out (FIFO) and Least Recently Used (LRU)?

  1. Both incur the same number of page faults
  2. FIFO incurs $2$ more page faults than LRU
  3. LRU incurs $2$ more page faults than FIFO
  4. FIFO incurs $1$ more page faults than LRU

2 Answers

Best answer
47 47 votes
Requested Page references are $3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3$ and number of page frames is $ 5$.

In FIFO Page replacement will take place  in sequence in pattern First In first Out, as following$$\small \begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline \textbf{Request} & \textbf{3} & \textbf{8} & \textbf{2} & \textbf{3} & \textbf{9} & \textbf{1} & \textbf{6} & \textbf{3} & \textbf{8} & \textbf{9} & \textbf{3} & \textbf{6} & \textbf{2} & \textbf{1} & \textbf{3} \\\hline \textbf{Frame 5} & \text{} & \text{} & \text{} & \text{} & \text{} & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\\hline \textbf{Frame 4} & \text{} & \text{} & \text{} & \text{} & 9 & 9 & 9 & 9 & 9 & 9 & 9 & 9 & 2 & 2 & 2\\\hline \textbf{Frame 3} & \text{} & \text{} & 2 & 2 & 2 & 2 & 2 & 2 & 8 & 8 & 8 & 8 & 8 & 8 & 8 \\\hline \textbf{Frame 2} & \text{} & 8 & 8 & 8 & 8 & 8 & 8 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 \\\hline \textbf{Frame 1} & 3 & 3 & 3 & 3 & 3 & 3 & 6 & 6 & 6 & 6 & 6 & 6 & 6 & 6 & 6 \\\hline \textbf{Miss/hit} & \text{F} & \text{F} & \text{F} & \text{H} & \text{F} & \text{F}&\text{F}& \text{F}& \text{F} & \text{H}& \text{H}& \text{H} & \text{F} & \text{H} & \text{H} \\\hline \end{array}$$Number of Faults $= 9.$ Number of Hits $= 6$

Using Least Recently Used (LRU) page replacement will be the page which is visited least recently (which is not used for the longest time), as following:$$\small \begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline \textbf{Request} & \textbf{3} & \textbf{8} & \textbf{2} & \textbf{3} & \textbf{9} & \textbf{1} & \textbf{6} & \textbf{3} & \textbf{8} & \textbf{9} & \textbf{3} & \textbf{6} & \textbf{2} & \textbf{1} & \textbf{3} \\\hline \textbf{Frame 5} & \text{} & \text{} & \text{} & \text{} & \text{} & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 2 & 2 & 2 \\\hline \textbf{Frame 4} & \text{} & \text{} & \text{} & \text{} & 9 & 9 & 9 & 9 & 9 & 9 & 9 & 9 & 9 & 9 & 9 \\\hline \textbf{Frame 3} & \text{} & \text{} & 2 & 2 & 2 & 2 & 2 & 2 & 8 & 8 & 8 & 8 & 8 & 1 & 1 \\\hline \textbf{Frame 2} & \text{} & 8 & 8 & 8 & 8 & 8 & 6 & 6 & 6 & 6 & 6 & 6 & 6 & 6 & 6 \\\hline \textbf{Frame 1} & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 & 3 \\\hline \textbf{Miss/hit} & \text{F} & \text{F} & \text{F} & \text{H} & \text{F} & \text{F}&\text{F}& \text{H}& \text{F} & \text{H}& \text{H}& \text{H} & \text{F} & \text{F} & \text{H} \\\hline \end{array}$$Number of Faults $= 9.$ Number of Hits $= 6$

So, both incur the same number of page faults.

Correct Answer: $A$
• edited by
16 16 votes

FIFO:

3 -3 :1 page fault
8 -3 8 :2 page faults
2 -3 8 2 :3 page faults
3 -3 8 2 :3 page faults
9 -3 8 2 9 :4 page faults
1 -3 8 2 9 1 :5 page faults
6 -8 2 9 1 6 :6 page faults
3 -2 9 1 6 3 :7 page faults
8 -9 1 6 3 8 :8 page faults
9 -9 1 6 3 8 :8 page faults
3 -9 1 6 3 8 :8 page faults
6 -9 1 6 3 8 :8 page faults
2 -1 6 3 8 2 :9 page faults
1 -1 6 3 8 2 :9 page faults
3 -1 6 3 8 2 :9 page faults

LRU:

3 -3 :1 page fault
8 -3 8 :2 page faults
2 -3 8 2 :3 page faults
3 -8 2 3 :3 page faults
9 -8 2 3 9 :4 page faults
1 -8 2 3 9 1 :5 page faults
6 -2 3 9 1 6 :6 page faults
3 -2 9 1 6 3 :6 page faults
8 -9 1 6 3 8 :7 page faults
9 -1 6 3 8 9 :7 page faults
3 -1 6 8 9 3 :7 page faults
6 -1 8 9 3 6 :7 page faults
2 -8 9 3 6 2 :8 page faults
1 -9 3 6 2 1 :9 page faults
3 -9 6 2 1 3 :9 page faults

So, option A. 

Answer:
Position:
Show:

Related questions

79 79 votes
11 answers 11 answers
34.0k
34.0k views
Misbah Ghaya asked Feb 13, 2015
33,955 views
Consider a disk pack with a seek time of $4$ milliseconds and rotational speed of $10000$ rotations per minute (RPM). It has $600$ sectors per track and each sector can s...
178 178 votes
17 answers 17 answers
65.7k
65.7k views
Misbah Ghaya asked Feb 13, 2015
65,709 views
Consider a uniprocessor system executing three tasks $T_{1}, T_{2}$ and $T_{3}$ each of which is composed of an infinite sequence of jobs (or instances) which arrive peri...
56 56 votes
7 answers 7 answers
42.2k
42.2k views
Misbah Ghaya asked Feb 13, 2015
42,186 views
Suppose the following disk request sequence (track numbers) for a disk with $100$ tracks is given:$45, 20, 90, 10, 50, 60, 80, 25, 70.$Assume that the initial position of...
68 68 votes
7 answers 7 answers
23.7k
23.7k views
Misbah Ghaya asked Feb 12, 2015
23,666 views
The following two functions $P1$ and $P2$ that share a variable $B$ with an initial value of $2$ execute concurrently.$$\begin{array}{|l|l|}\hline \text{P1() \{ } & \tex...