Copy-on-write: Difference between revisions

Content deleted Content added
In virtual memory management: Copyedit: simplify pointless usage of openat(3)
Line 12:
 
Copy-on-write pages are also used in the [[Linux kernel]]'s [[Kernel same-page merging|same-page merging]] feature.<ref>{{cite web|last=Abbas|first=Ali|title=The Kernel Samepage Merging Process|url=http://alouche.net/blog/2011/07/18/the-kernel-samepage-merging-process/|website=alouche.net|access-date=4 August 2016|archive-url=https://web.archive.org/web/20160808174912/http://alouche.net/blog/2011/07/18/the-kernel-samepage-merging-process/|archive-date=8 August 2016 }}</ref>
 
Loading the libraries for an application is also a use of copy-on-write technique. The dynamic linker maps libraries as private like follows. Any writing action on the libraries will trigger a COW in virtual memory management.
<syntaxhighlight lang="c">
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
mmap(NULL, 3906144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)
mmap(0x7f8a3ced4000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b0000)
</syntaxhighlight>
 
==In software==