Copy on Write. An attribute of some paging systems for implementing virtual memory. Most modern Unices use CoW when fork()ing a new process.

To clone a new process, the OS must arrange for it to see an exact copy of the current memory space. Some pages (like "text", the executable program code) are read only, so can be shared between both tines of the fork. Pages holding writable data must appear the same to both tines, but are not shared (writing on one tine does not change the other tine's memory). The easy way out is to copy all pages of writable data in the child process.

Unfortunately, this is very wasteful both of (virtual) memory and of CPU time. Typically, a large proportion of memory remains unchanged in both processes, so there is no need to copy it. In particular, in the fork() then exec*() paradigm (used to run a new program) the child process writes almost nothing before clearing all its virtual memory space with the new program. So copying is inherently wasteful.

A better solution is to share all pages, but to mark writable pages as unwritable but copy on write. When (IF) either tine tries to write to such a page, the OS is notified (it's unwritable) with a page fault. The OS can then make a fresh writable (unshared) copy of the page and map it into the writing process' address space instead of the faulting page. (Depending on how many other processes share the original page, that too may become unshared writable).

Time spent fork()ing the new process is still linear in the size of the process' memory space, but with a much smaller constant multiplier: instead of copying each page, it only needs to be marked copy on write (and, typically, a reference count set). Generally, the results are highly beneficial.