Content deleted Content added
The RedBurn (talk | contribs) →In computer storage: ReFS -> section, +Bcachefs |
m Citation added |
||
Line 5:
==In virtual memory management==
Copy-on-write finds its main use in [[operating system]]s, sharing the [[physical memory]] of computers running multiple [[Process (computing)|processes]], in the implementation of the [[Fork (system call)|fork() system call]]. Typically, the new process does not modify any memory and immediately executes a new process, replacing the address space entirely. It would waste processor time and memory to copy all of the old process's memory during the fork only to immediately discard the copy.{{Citation needed|date=November 2023}}<ref>{{Cite book |first=Silberschatz, A., Galvin, P. B., & Gagne |title=Operating System Concepts |publisher=Wiley |year=2018 |isbn=978-1119456339 |edition=10th ed |pages=Pages 120–123}}</ref>
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 operating-system [[Kernel (operating system)|kernel]] intercepts the write attempt and allocates a new physical page, initialized with the copy-on-write data, although the allocation can be skipped if there is only one reference. The kernel then updates the page table with the new (writable) page, decrements the number of references, and performs the write. The new allocation ensures that a change in the memory of one process is not visible in another's.{{Citation needed|date=November 2023}}
|