Content deleted Content added
→In high-reliability software: This reads like an advertisement. |
Disambiguated: kernel (computing) → kernel (operating system) |
||
Line 7:
Copy-on-write finds its main use in sharing the [[virtual memory]] of [[operating system]] [[computer process|process]]es, in the implementation of the [[Fork (system call)|fork system call]]. Typically, the process does not modify any memory and immediately executes a new process, replacing the address space entirely. Thus, it would be wasteful to copy all of the process's memory during a fork, and instead the copy-on-write technique is used.
Copy-on-write can be implemented efficiently using the [[page table]] by marking certain pages of [[computer storage|memory]] as read-only and keeping a count of the number of references to the page. When data is written to these pages, the [[kernel (
The copy-on-write technique can be extended to support efficient [[memory allocation]] by having a page of [[physical memory]] filled with zeros. When the memory is allocated, all the pages returned refer to the page of zeros and are all marked copy-on-write. This way, physical memory is not allocated for the process until data is written, allowing processes to reserve more virtual memory than physical memory and use memory sparsely, at the risk of running out of virtual address space. The combined algorithm is similar to [[demand paging]].<ref name="Linux" />
|