LearnFrenzy
Sign in Take a free test

Operating Systems · Topic 7 of 11

Virtual Memory and Page Replacement: questions with answers

Demand paging and page faults, FIFO, LRU, Optimal and clock replacement traced on reference strings, Belady's anomaly, effective access time with faults, thrashing, working sets and frame allocation.

Questions
45
Timed sets
3
Answers run or computed
22
Your accuracy
–

What this topic covers

11 subtopics
  • Demand paging7
  • FIFO7
  • LRU6
  • Performance5
  • Linux4
  • Clock3
  • Comparison3
  • Thrashing3
  • Working set3
  • Frame allocation2
  • Optimal2
  • Beginner 15
  • Intermediate 15
  • Advanced 15

About this topic

Page-replacement numericals are GATE and placement favourites: given a reference string and a number of frames, count the page faults for FIFO, LRU and Optimal. Reference strings are drawn here, and some questions show the frames over time as a table. Frames start empty, every first load counts as a fault, and every count was produced by running the algorithm.

Free preview

Sample questions

Try each one first, then open the answer for the explanation and why the other options are wrong.

Question 1 FIFO Beginner Practice Answer computed

With 3 frames, initially empty, how many page faults does FIFO cause for this reference string?

Reference string
  1. 7
  2. 0
  3. 1
  4. 2
  5. 0
  6. 3
  7. 0
  8. 4
  9. 2
  10. 3
  11. 0
  12. 3
  13. 2
  14. 1
  15. 2
  16. 0
  17. 1
  18. 7
  19. 0
  20. 1

The answer is a number – work it out, then open the solution.

Show answer and explanation
Correct answer 15

Explanation

15 faults and only 5 hits. FIFO evicts the page that was loaded earliest, however recently it was used – so it keeps throwing out page 0, which this string uses again and again.

Question 2 FIFO Intermediate Practice Answer computed

FIFO on this string with 3 frames and with 4 frames. How many faults in each case?

Reference string
  1. 1
  2. 2
  3. 3
  4. 4
  5. 1
  6. 2
  7. 5
  8. 1
  9. 2
  10. 3
  11. 4
  12. 5
9 with 3 frames, 8 with 4 frames
9 with 3 frames, 10 with 4 frames
12 with 3 frames, 12 with 4 frames
10 with 3 frames, 9 with 4 frames
Show answer and explanation
Correct answer B

Explanation

This is the classic string demonstrating Belady's anomaly: the extra frame makes FIFO fault once more. LRU on the same string gives 10 and 8.

Why the other options are wrong

  • AThat would be normal behaviour.
  • CThere are hits.
  • DSwapped.
Question 3 Comparison Advanced Practice Answer computed

With 3 frames, how many faults do FIFO, LRU and Optimal cause on this string?

Reference string
  1. 1
  2. 2
  3. 3
  4. 4
  5. 2
  6. 1
  7. 5
  8. 6
  9. 2
  10. 1
  11. 2
  12. 3
  13. 7
  14. 6
  15. 3
  16. 2
  17. 1
  18. 2
  19. 3
  20. 6
FIFO 15, LRU 16, OPT 11
FIFO 16, LRU 12, OPT 9
FIFO 14, LRU 10, OPT 8
FIFO 16, LRU 15, OPT 11
Show answer and explanation
Correct answer D

Explanation

With 4 frames the counts drop to 14, 10 and 8. LRU is only slightly better than FIFO here because the string jumps between localities.

Why the other options are wrong

  • ALRU beats FIFO here.
  • BThose are the classic string's counts.
  • CThose are with 4 frames.
42 more questions in the timed setsSame format as the samples, with a timer, a question palette and a full review at the end.
Start practising

Operating Systems

All 11 topics

Topics, levels and full mocks
  1. 01 OS Basics and System Calls45 questions · 3 levels
  2. 02 Processes, Threads and fork()45 questions · 3 levels
  3. 03 CPU Scheduling Algorithms45 questions · 3 levels
  4. 04 Process Synchronization and Semaphores45 questions · 3 levels
  5. 05 Deadlocks and Banker's Algorithm45 questions · 3 levels
  6. 06 Memory Management and Paging45 questions · 3 levels
  7. 07 Virtual Memory and Page Replacement45 questions · 3 levels
  8. 08 File Systems and Disk Scheduling45 questions · 3 levels
  9. 09 Threads and Concurrency in Code45 questions · 3 levels
  10. 10 Linux Commands and Shell45 questions · 3 levels
  11. 11 GATE-Style OS Questions (MSQ & NAT)45 questions · 3 levels

Search LearnFrenzy

Esc

Quick links