0
0
Operating Systemsknowledge~3 mins

Why Copy-on-write technique in Operating Systems? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could save huge amounts of memory by copying only when absolutely needed?

The Scenario

Imagine you have a large document that you want to share with a friend, but you both want to make changes independently. Without a smart method, you'd have to make a full copy of the entire document for your friend, even if they only change a small part.

The Problem

Making full copies every time wastes a lot of space and time. It slows down your system and uses up memory quickly. This manual copying is inefficient and can cause delays, especially when dealing with big files or many users.

The Solution

The copy-on-write technique solves this by letting both users share the same original document until one of them makes a change. Only then does the system create a copy of the part that changes, saving space and speeding up operations.

Before vs After
Before
copy = full_copy(original)
modify(copy)
After
copy = shared_reference(original)
if modify_needed:
    copy = copy_changed_part(copy)
What It Enables

It enables efficient memory and storage use by delaying copying until absolutely necessary, making systems faster and more resource-friendly.

Real Life Example

When you open a file in an operating system and create a new process, the system uses copy-on-write to avoid copying the entire file immediately, only copying parts if changes happen.

Key Takeaways

Manual copying wastes time and space.

Copy-on-write shares data until changes occur.

This technique improves system speed and efficiency.