3,915 views
1 votes
1 votes
"In a technique called COPY ON WRITE, when a fork occurs, the parent process's pages are not copied for the child process. Instead, the pages are shared between the child and the parent process. Whenever a process (parent or child) modifies a page, a separate copy of that particular page alone is made for that process (parent or child) which performed the modification."

Does it mean that when a child process is created..both parent and child share the same pages of the process also the same page table..So all the variables will have the same address for both parent and child.

suppose child tries to modify any page then that particular page will be copied for child and it will point to a different frame in main memory.

2 Answers

0 votes
0 votes
when a process calls fork() which returns pid>0 for parent and pid=0 for child

there can be two cases for child:

1. Address space is exact duplicate of parent(code,data,program etc) are same as parent.

2. sepeerate address space is created for child
0 votes
0 votes

Acc. to my understanding from GO:

when a process calls fork() system call :

  1. A new child process got created which is the clone of the parent process.
  2. Both parent and child have the same code, data segment, program counter( so the next instruction to be executed would be the same), etc.
  3. parent and child’s VAS(virtual address space ) are different, though they have the same relative location of variables ( so same VA of variables)
  4. Both have their separate Page Tables.
  5. Initially, parent and child share the same Physical address space as long as both are reading. then their page tables and PAS start to diverge as each COW(Copy on Write) fault occurs.

References : 

http://www.csl.mtu.edu/cs4411.ck/www/NOTES/process/fork/create.html

https://gateoverflow.in/765/gate2005-72?show=326465#c326465

Related questions

0 votes
0 votes
1 answer
3
Aspi R Osa asked Jan 21, 2016
316 views
if multiple forks are given. then multiple processes will be created. Are all children created through first child are counted as children only?
0 votes
0 votes
1 answer
4
dd asked Sep 13, 2018
509 views
A one-to-one mapping of the entire physical address space to a process's virtual address space is a correct address translation solution. True/False. Explain.