Process Creation and Copy-on-Write

Share parent and child pages while their contents agree and make a private copy when a writer needs isolation.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. A new process can reuse physical memory initially
  2. A write triggers a mapping change under protection

A new process can reuse physical memory initially

In a fork-style operation, the child receives the specified initial logical address-space contents. Instead of immediately copying each private page, the kernel can let both page tables refer to the same frames and mark those mappings for copy-on-write. Reads see the same original data. Reference bookkeeping ensures a frame remains available while either process uses it.

A write triggers a mapping change under protection

A write to such a page faults because the mapping does not yet allow that direct write. The handler recognizes copy-on-write, creates a private copy when needed, changes the writer’s mapping and resumes the instruction. If the parent changes one private page, the child can continue seeing the old contents. Shared mappings have a different contract. Demand paging examines other reasons for a valid fault. Page permissions and translation explain which mapping is changed.[1]

References

  1. Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau, Operating Systems: Three Easy Pieces ↩