Scope of pointers after fork()

Jan 31, 2009 at 10:40am
So I am having trouble figuring out which of the following is true for my program:

1. After executing fork() any pointers will point to separate memory locations in the parent and child process once either tries to write to it (assuming Copy on write)

or

2. They are pointers, they will always contain the physical memory location no matter what.

I can justify both in my mind, and I could't find anything definative on GOOGLE.

Jared
Jan 31, 2009 at 4:24pm
All user-land pointers are pointers into the virtual address space; as a user you never see pointers to physical memory.

On fork(), the child's process image is identical to that of the parent. On most OSes I know of, both the child's are parent's address spaces both reference the same underlying physical memory until one or the other writes to the page, at which point the OS gives the parent and child unique copies. (So called copy-on-write semantics).
Jan 31, 2009 at 8:54pm
Alright. Thanks.

Jared
Topic archived. No new replies allowed.