previous | start | next

fork

With virtual memory the fork function doesn't actually make a copy of the parent's text, data, heap, or stack segments.

Instead, a copy of the mm_struct, segment structs, and page tables are copied.

The vm_flag in each segment struct is set as private copy-on-write.

So parent and child actually share the same physical memory as long as the memory content is not modified.

When either process writes (stores) to a memory location, a copy is first made of that page and the store only happens in that process's copy.



previous | start | next