CS FundamentalsHardTCS NQT · Infosys pattern
Copy-on-write (COW) is used after fork() to avoid copying the entire parent's address space immediately. How does it work?
- A. Both processes share the same physical pages marked read-only; a private copy of a page is made only when either process tries to write to it
- B. It copies all pages immediately but compresses them to save space
- C. It never actually copies anything, so writes by the child are visible to the parent
- D. It only applies to the stack segment, never the heap or data segment
Correct answer: A. Both processes share the same physical pages marked read-only; a private copy of a page is made only when either process tries to write to it
COW maps parent and child to the same physical frames, marked read-only. A write triggers a protection fault; the kernel then allocates a new physical frame, copies the page's contents, and remaps just that page for the writer — so unmodified pages (often most of them, especially before an exec()) are never duplicated.
More Operating Systems questions
- A process has a single-level page table with a 'valid/invalid' bit per entry. A memory reference to a page marked invalid causes a page…
- Memory-mapped files (via mmap) let a process treat a file's contents as part of its address space. Compared to read()/write() calls, what…
- Swap space (backing store) on disk lets the OS support more processes than fit entirely in physical RAM. Which statement about it is…
- RAID 5 stripes data across N disks and stores a rotating parity block (the XOR of the corresponding data blocks) on a different disk for…
- An array has 5 disks in RAID 5 (4 data + 1 rotating parity per stripe, effectively). Compared to plain striping (RAID 0) across the same 5…
- A disk subsystem uses C-LOOK (like C-SCAN, but it jumps straight to the lowest pending request instead of running all the way to the…