Questions: Copy-on-Write Memory Optimization

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A process with 200MB of memory calls fork(), and the child immediately calls exec(). With copy-on-write enabled, approximately how much memory is actually copied during this sequence?

A200MB — all of the parent's address space must be duplicated at fork() time
B100MB — only writable pages are copied; code pages are shared
CA few kilobytes — only the page tables are duplicated; data pages are never written before exec() replaces them
DNothing — exec() makes any memory copying completely unnecessary
Question 2 Multiple Choice

After fork() with copy-on-write, a page is marked read-only in both the parent and child page tables. The parent then writes to that page. What happens next?

AThe write is silently ignored to preserve the shared copy
BA segmentation fault is raised because the page is read-only
CThe OS copies the page for the parent, updates the parent's page table to point to the new copy with write permission, and the child keeps the original
DThe OS copies the page for the child, and both parent and child receive new independent copies
Question 3 True / False

With copy-on-write, parent and child processes share physical memory pages until one of them reads those pages.

TTrue
FFalse
Question 4 True / False

Copy-on-write relies on the page fault mechanism to defer copying until a write actually occurs.

TTrue
FFalse
Question 5 Short Answer

Explain why copy-on-write makes fork() followed immediately by exec() nearly free in terms of memory copying.

Think about your answer, then reveal below.