Before copy on write (COW)
, when it says that the parent and child process share the same address space, it means that they share the same code segment, data segment, heap and stack right?
If the parent and child process share the same address space before COW, what does the page table entries are copied from parent process to child process
mean?
Does duplicating the page table entries mean duplicating the address space?
lets say your process is got var name X that have a virtual address 100 and physical address 200. the PTE is holding a mapping of addresses from virtual 100 to physical 200.
after the fork, each process (parent and child) will have his private PTE. at this point both PTEs will map virtual 100 to physical 200.
as long as both process just read from there they both will read from physical address 200.
when the first one will try to write there, the data from physical address will be copy to a new physical space, lets say 300, and his (and only his) PTE will be update so virtual 100 will be mapped to physical 300. that way it's transparent to the process because he is still using the same (virtual) address.
*Note: this is just an abstract, and the real thing is happening in page resolution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With