From 54c67417143b645bf5ffac814692d35c87fab732 Mon Sep 17 00:00:00 2001 From: Colfenor <34011017+Colfenor@users.noreply.github.com> Date: Fri, 30 Dec 2022 17:26:06 +0100 Subject: [PATCH] add answer to COW question (#329) --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d82c75..37c19d0 100644 --- a/README.md +++ b/README.md @@ -708,7 +708,15 @@ https://www.minitool.com/lib/virtual-memory.html
-What is copy-on-write or shadowing?
+What is copy-on-write?
+Copy-on-write (COW) is a resource management concept, with the goal to reduce unnecessary copying of information. It is a concept which is implemented for instance within the POSIX fork syscall, which creates a duplicate process of the calling process. + +The idea: +1. If resources are shared between 2 or more entities (for example shared memory segments between 2 processes) the resources don't need to be copied for every entity, but rather every entity has a READ operation access permission on the shared resource. (the shared segements are marked as read-only) +(Think of every entity having a pointer to the location of the shared resource which can be dereferenced to read its value) +2. If one entity would perform a WRITE operation on a shared resource a problem would arise since the resource also would be permanently changed for ALL other entities sharing it. +(Think of a process modifying some variables on the stack, or allocatingy some data dynamically on the heap, these changes to the shared resource would also apply for ALL other processes, this is definetly an undesirable behaviour) +3. As a solution only if a WRITE operation is about to be performed on a shared resource, this resource gets COPIED first and then the changes are applied.