CS FundamentalsVery hardGATE CS (PYQ pattern)

NRU replacement runs with 3 frames (initially empty). Each page has bits (R, M): R is set on every reference, M on every write, and a newly loaded page starts at (0, 0) before its reference is applied. After every 4th reference (after references 4, 8, 12, ...) the OS clears R of all resident pages. On a fault with no free frame the victim comes from the lowest non-empty class (0,0) < (0,1) < (1,0) < (1,1), ties going to the lowest-numbered frame; frames are filled 0, 1, 2. A dirty victim must be written back. References (R = read, W = write): 1R 2W 3R 1W 4R 2R 5W 1R 3W 2R 4W 5R 1R 3R. How many page faults and write-backs occur?

  1. A. 10 faults, 3 write-backs
  2. B. 9 faults, 3 write-backs
  3. C. 10 faults, 5 write-backs
  4. D. 11 faults, 3 write-backs

Correct answer: A. 10 faults, 3 write-backs

Faults at refs 1, 2, 3, then 4R evicts 3 (class (0,0) after the clear), 5W evicts dirty 1 (class (0,1)), 1R evicts 4 (class (1,0)), 3W evicts 1 (clean), 4W evicts dirty 5, 5R evicts dirty 4, 1R evicts clean 5 after the clear at 12. That is 10 faults and 3 write-backs (pages 2 and 3, still dirty at the end, are not counted). Never clearing R gives 9 faults.

More Operating Systems questions

Exams that ask this topic