Operating System MCQs - Page Replacement, Thrashing and Belady's Anomaly (Set 5)

Operating System MCQs - Page Replacement, Thrashing and Belady's Anomaly (Set 5) - CodingHumans

Page replacement questions appear in almost every GATE paper and OS viva because they test both the algorithms and the reasoning behind them. This set works through FIFO, LRU and Optimal on a standard reference string, then covers Belady's anomaly, the clock algorithm, thrashing, the working set model and effective access time, with a step-by-step explanation for each answer.

How to practise: read each question and tap the option you think is correct. You will see right away whether you got it, along with a short explanation, and your score is tracked at the bottom of the screen. This set has 15 questions.

Topics covered in this set

  • FIFO, LRU and Optimal page replacement
  • Belady's anomaly and stack algorithms
  • Second chance (clock) and the dirty bit
  • Thrashing and its causes
  • Working set model and page fault frequency
  • Effective access time with page faults

Operating System MCQs with answers and explanations

Q1. Using FIFO page replacement with 3 frames (initially empty), how many page faults occur for the reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1?

a) 12

b) 15

c) 9

d) 14

Q2. Using LRU page replacement with 3 frames for the same string (7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1), how many page faults occur?

a) 12

b) 10

c) 15

d) 11

Q3. Using the Optimal (OPT) algorithm with 3 frames for the same string (7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1), how many page faults occur?

a) 8

b) 10

c) 12

d) 9

Q4. Belady's anomaly can occur with which page replacement algorithm?

a) LRU

b) Optimal

c) FIFO

d) All of these

Q5. For the reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 under FIFO, how many page faults occur with 3 frames and with 4 frames?

a) 9 and 8

b) 9 and 10

c) 10 and 9

d) 12 and 10

Q6. Why is the Optimal page replacement algorithm not used in real operating systems?

a) It needs knowledge of future page references

b) It suffers from Belady's anomaly

c) It needs too many frames

d) It cannot handle dirty pages

Q7. The second chance (clock) algorithm is a modification of which algorithm?

a) Optimal

b) LFU

c) Random

d) FIFO

Q8. What is the purpose of the dirty (modify) bit in a page table entry?

a) To mark pages that are shared

b) To avoid writing an unmodified page back to disk when it is replaced

c) To mark pages that caused a fault

d) To lock a page in memory

Q9. In the enhanced second chance algorithm, which (reference bit, modify bit) class is the best candidate for replacement?

a) (0, 0)

b) (0, 1)

c) (1, 0)

d) (1, 1)

Q10. Thrashing occurs when:

a) The CPU scheduler uses round robin

b) A process spends more time paging than executing

c) The TLB hit ratio is very high

d) Too few processes are in memory

Q11. Under the working set model, what should the OS do if the total working set size of all processes exceeds the number of available frames?

a) Add more processes

b) Switch to FIFO replacement

c) Suspend (swap out) one or more processes

d) Increase the time quantum

Q12. In the page fault frequency (PFF) scheme, what happens when a process's fault rate rises above the upper threshold?

a) The process is given more frames

b) The process loses frames

c) The process is terminated

d) Nothing changes

Q13. Memory access time is 100 ns and the page fault service time is 10 ms. If the page fault rate is 0.001, what is the effective access time?

a) About 200 ns

b) About 1.1 microseconds

c) About 10.1 microseconds

d) About 100 microseconds

Q14. What is the difference between global and local page replacement?

a) Global replacement can take a frame from any process; local replacement uses only the faulting process's frames

b) Global is used for kernel pages only

c) Local replacement uses LRU and global uses FIFO

d) There is no difference

Q15. In pure demand paging, how many pages of a process are in memory when it starts executing?

a) All of its pages

b) Half of its pages

c) Only the pages in its working set

d) None

Quick revision notes

  • FIFO evicts the oldest page, LRU the least recently used page, and OPT the page used furthest in the future.
  • Belady's anomaly (more frames, more faults) can occur with FIFO, not with stack algorithms such as LRU and OPT.
  • Clock (second chance) = FIFO plus a reference bit; it is a cheap approximation of LRU.
  • Only dirty pages need to be written to disk when they are replaced.
  • Thrashing: high paging activity and low CPU utilisation. Fix it with the working set model, PFF or by reducing the degree of multiprogramming.
  • EAT = (1 - p) x memory access time + p x page fault service time.

Frequently asked questions

How do I solve page replacement questions quickly in exams?

Write the frames as columns under the reference string and mark each fault. For LRU, look backwards to find the page used longest ago; for OPT, look forwards to find the page needed latest. Count the faults at the end, including the first ones that fill empty frames.

Does LRU suffer from Belady's anomaly?

No. LRU is a stack algorithm: the pages held with n frames are always a subset of those held with n + 1 frames, so adding frames can never increase the number of faults.

What is the main cause of thrashing?

Too many processes competing for too few frames. Each process cannot keep its working set in memory, so it faults constantly and the CPU spends its time waiting for the disk.

Comments

Answered 0/0Correct 0