CITS2002 Systems Programming  
prev
next CITS2002 CITS2002 schedule  

Memory in Parent and Child Processes

The (existing) parent process and the (new) child process continue their own execution.

Importantly, both the parent and child have their own copy of their program's memory (variables, stack, heap).

The parent naturally uses the memory that it had before it called fork(); the child receives its own copy of the same memory. The copy is made at the time of the fork().

As execution proceeds, each process may update its own memory without affecting the other process.

 

 

[ OK, I lied - on contemporary operating systems, the child process does not receive a full copy of its parent's memory at the time of the fork():

  • the child can share any read-only memory with its parent, as neither process can modify it.
  • the child's memory is only copied from the parent's memory if either the parent modies its (original) copy, or if the child attempts to write to its copy (that it hasn't yet received!)
  • this sequence is termed copy-on-write.
]

 


CITS2002 Systems Programming, Lecture 9, p5, 19th August 2024.