CS FundamentalsVery hardGATE CS (PYQ pattern)

A process owns 100 private writable pages. It calls fork() and both processes use copy-on-write. Before either exits, the child writes to 30 distinct pages and the parent writes to 20 distinct pages, 10 of which are also among the child's 30. When a write finds the page shared by only one process the kernel simply makes it writable again without copying. How many new physical pages are allocated by these writes?

  1. A. 40
  2. B. 50
  3. C. 30
  4. D. 60

Correct answer: A. 40

A page is copied only by the FIRST writer; after that the other process is the sole owner and writes in place. So the copies equal the union of written pages: 30 + 20 - 10 = 40. 50 counts the shared 10 twice.

More Operating Systems questions

Exams that ask this topic