Suppose a process has 400 MiB of initialized heap memory and calls fork().
The child must initially see the same memory as the parent, but copying all 400 MiB immediately would be wasteful. The child may soon call exec(), or it may read the data without modifying it.
Instead, the operating system initially lets both processes share the same physical memory pages. If either process writes to a shared page, a page fault occurs and the kernel creates a private copy for that process.
This technique is called copy-on-write (CoW).
Copy-on-write shares memory until a write requires the parent and child to have different contents.
This avoids unnecessary copying. Pages that are never modified remain shared.
This chapter follows copy-on-write setup and write-fault handling, explains page-granularity copying, reference counts, TLB consistency, concurrent writes, and memory accounting, and shows why CoW makes fork inexpensive.