in Operating System recategorized by
1,031 views
1 vote
1 vote

Determine the number of page faults when references to pages occur in the 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 $1$ having brought earlier than page $2$. (assume LRU i.e. Least-Recently-Used algorithm is applied)

  1. $3$
  2. $4$
  3. $5$
  4. None of the above
in Operating System recategorized by
by
1.0k views

1 comment

Ans B) 4


X: NO FAULT

F: FAULT

Initially, we have: Top 2,1 Bottom

Page Ref
1 2 4 5 2 1 2 4
X X F F X F X F
    4 5 2 1 2 4
1 2 2 4 5 2 1 2
2 1 1 2 4 5 5 1
0
0

2 Answers

5 votes
5 votes
Best answer

Reference String: $1,2,4,5,2,1,2,4$

Frame can contain only $3$ pages, $1$ and $2$ are already present

$1$: Hit, Frame Status: $1,2$

$2$: Hit, Frame Status: $1,2$

$4$: Page fault, Frame Status: $1,2,4$

$5$: Page fault, $1$ will be replaced as per LRU policy, Frame Status: $5,2,4$

$2$: Hit, Frame Status: $5,2,4$

$1$: Page fault, $4$ will be replaced, Frame Status: $5,2,1$

$2$: Hit, Frame Status: $5,2,1$

$4$: Page fault, $5$ will be replaced, Frame Status: $4,2,1$

4 Page faults hence option B) is correct

selected by
1 vote
1 vote

option b

Answer:

Related questions