GateAI
Memory Management and Virtual Memory

GATE CSE 2016 Set 1 · Q49

NAT2 marksHard

Time

Consider a computer system with ten physical page frames. The system is provided with an access sequence (a1,a2,…,a20,a1,a2,…,a20)(a_1, a_2, \ldots, a_{20}, a_1, a_2, \ldots, a_{20}), where each aia_i is a distinct virtual page number. The difference in the number of page faults between the last-in-first-out page replacement policy and the optimal page replacement policy is ________.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 1

Memory Management and Virtual Memory

We are given 1010 physical frames and an access string of 4040 page accesses containing 2020 distinct pages repeated twice:

(a1,a2,…,a20,a1,a2,…,a20)(a_1, a_2, \ldots, a_{20}, a_1, a_2, \ldots, a_{20})

### 1. Last-In-First-Out (LIFO) Policy:

  • First 10 accesses (a1a_1 to a10a_{10}): Each page misses and is placed into an empty frame. Frame content: {a1,a2,…,a10}\{a_1, a_2, \ldots, a_{10}\}. (10 faults)

  • Next 10 accesses (a11a_{11} to a20a_{20}):

    • a11a_{11} replaces a10a_{10} (the last inserted page). Frame: {a1,…,a9,a11}\{a_1, \ldots, a_9, a_{11}\}.

    • a12a_{12} replaces a11a_{11}, and so on, until a20a_{20} replaces a19a_{19}. Frame content at the end of the first pass: {a1,a2,…,a9,a20}\{a_1, a_2, \ldots, a_9, a_{20}\}. (10 faults)

  • Second pass (a1a_1 to a20a_{20}):

    • a1a_1 through a9a_9 are all hits because they remained in the first 99 frames (0 faults).

    • a10a_{10} misses and replaces a20a_{20}. Frame: {a1,…,a9,a10}\{a_1, \ldots, a_9, a_{10}\}. (1 fault)

    • a11a_{11} through a20a_{20} all miss, each replacing the previously inserted page (10 faults).

  • Total faults for LIFO =10+10+0+1+10=31= 10 + 10 + 0 + 1 + 10 = 31.

### 2. Optimal (OPT) Policy:

  • First 10 accesses (a1a_1 to a10a_{10}): All miss and fill the 10 frames (10 faults).

  • Accesses a11a_{11} to a20a_{20}:

    • In the future, pages a1,…,a9a_1, \dots, a_9 will be accessed earlier in the second pass than a10,a11,…a_{10}, a_{11}, \dots

    • Thus, OPT always replaces the page that is needed furthest in the future. It can retain {a1,…,a9,a20}\{a_1, \ldots, a_9, a_{20}\} or any 10 pages for the second pass.

    • Each of a11,…,a20a_{11}, \ldots, a_{20} causes a fault (10 faults).

  • Second pass:

    • Exactly 1010 pages residing in frames will result in hits (a1,…,a9a_1, \ldots, a_9 and a20a_{20}), while the remaining 1010 pages fault (10 faults).

  • Total faults for OPT =10+10+10=30= 10 + 10 + 10 = 30.

### Difference:

Difference=FaultsLIFO−FaultsOPT=31−30=1\text{Difference} = \text{Faults}_{\text{LIFO}} - \text{Faults}_{\text{OPT}} = 31 - 30 = 1

Thus, the difference is 1.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Memory Management and Virtual Memory previous year question is Q49 of the GATE CSE 2016 Set 1 paper. Find more GATE CSE PYQs on Memory Management and Virtual Memory in Operating Systems, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Memory Management and Virtual Memory PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Memory Management and Virtual Memory in GATE CSE

Memory Management and Virtual Memory has 32 GATE CSE PYQs across 22 papers from 2011 to 2026. 15 of them are 2-mark NAT questions like this one, and GATE CSE 2016 Set 1 has 2.

How GATE tests Memory Management and Virtual Memory

More from GATE CSE 2016 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 1 · Q49 · NAT

Consider a computer system with ten physical page frames. The system is provided with an access sequence (a1, a2, , a20, a1, a2, , a20), where each ai is a distinct virtual page number. The difference in the number of page faults between the last-in-first-out page replacement policy and the optimal page replacement policy is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.