Copy-on-write (sometimes referred to as "COW"), sometimes referred to as
implicit sharing, is an
optimization strategy used in
computer programming. Copy-on-write stems from the understanding that when multiple separate tasks use initially identical copies of some information (i.e., data stored in
computer memory or
disk storage), treating it as local data, each task working on its own "copy of the data", that they may occasionally need to modify, then it is not necessary to immediately create separate copies of that information for each task. Instead they can all be given pointers to the same resource, with the provision that on the first occasion where they need to modify the data, they must first create a local copy on which to perform the modification (the original resource remains unchanged). When there are many separate processes all using the same resource, each with a small likelihood of having to modify it at all, then it is possible to make significant resource savings by sharing resources this way. Copy-on-write is the name given to the policy that whenever a task attempts to make a change to the shared information, it should first create a separate (private) copy of that information to prevent its changes from becoming visible to all the other tasks. If this policy is enforced by the
operating system kernel, then the fact of being given a reference to shared information rather than a private copy can be
transparent to all tasks, whether they need to modify the information or not.