Copy-on-write: Difference between revisions

Content deleted Content added
Adding local short description: "Programming technique for efficiently duplicating data", overriding Wikidata description "a resource-management technique used in computer programming to efficiently implement a "duplicate" or "copy" operation on modifiable resources" (Shortdesc helper)
Citation bot (talk | contribs)
Alter: url. URLs might have been internationalized/anonymized. Add: s2cid. | You can use this bot yourself. Report bugs here. | Suggested by AManWithNoPlan | All pages linked from cached copy of User:AManWithNoPlan/sandbox2 | via #UCB_webform_linked
Line 2:
{{More citations needed|date=August 2020}}
 
'''Copy-on-write''' ('''COW'''), sometimes referred to as '''implicit sharing'''<ref>{{cite web|title= Implicit Sharing|url= http://doc.qt.io/qt-5/implicit-sharing.html|website= Qt Project|accessdate= 4 August 2016}}</ref> or '''shadowing''',<ref>{{cite journal|last= Rodeh|first= Ohad|title= B-Trees, Shadowing, and Clones|journal= ACM Transactions on Storage|date= 1 February 2008|volume= 3|issue= 4|page= 1|doi= 10.1145/1326542.1326544|url= http://liw.fi/larch/ohad-btrees-shadowing-clones.pdf |accessdate= 4 August 2016|citeseerx= 10.1.1.161.6863|s2cid= 207166167}}</ref> is a resource-management technique used in [[computer programming]] to efficiently implement a "duplicate" or "copy" operation on modifiable resources.<ref name="Linux">{{cite book |title=Understanding the Linux Kernel |url=https://books.google.com/books?id=9yIEji1UheIC&lpg=PA295&dqq=%22copy%20on%20write%22&pg=PA295 |last1=Bovet |first1=Daniel Pierre |last2=Cesati |first2=Marco |date=2002-01-01 |publisher=O'Reilly Media |isbn=9780596002138 |___location= |page=295}}</ref> If a resource is duplicated but not modified, it is not necessary to create a new resource; the resource can be shared between the copy and the original. Modifications must still create a copy, hence the technique: the copy operation is deferred until the first write. By sharing resources in this way, it is possible to significantly reduce the resource consumption of unmodified copies, while adding a small overhead to resource-modifying operations.
 
==In virtual memory management==
Line 27:
 
===Examples===
The [[String (C++)|string]] class provided by the [[C++ standard library]] was specifically designed to allow copy-on-write implementations in the initial C++98 standard,<ref name="meyers">{{citation |first=Scott |last=Meyers |authorlink=Scott Meyers |year=2012 |title=Effective STL |publisher=Addison-Wesley |pages=64–65 |url=https://books.google.nlcom/books?id=U7lTySXdFk0C&pg=PT734|isbn=9780132979184 }}</ref> but not in the newer C++11 standard:<ref>{{cite web|title=Concurrency Modifications to Basic String|url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2534.html|website=Open Standards|accessdate=13 February 2015}}</ref>
<syntaxhighlight lang="cpp">
std::string x("Hello");