Introduction
Imagine you want to share a document with a friend without making a full copy right away. Copy-on-write solves the problem of saving memory and time by delaying copying until absolutely necessary.
Imagine two friends sharing a single printed book. They both read the same pages without making copies. Only if one friend wants to write notes in the book does she make her own copy to write on, leaving the original book clean for the other.
┌───────────────┐ ┌───────────────┐
│ Shared Memory │◄──────│ Process A │
└───────────────┘ └───────────────┘
▲ ▲
│ │
│ │
┌───────────────┐ ┌───────────────┐
│ Shared Memory │◄──────│ Process B │
└───────────────┘ └───────────────┘
When Process A writes:
Process A copies shared memory → gets own copy
Process B still uses original shared memory