I still don't really follow what point you're trying to make, but you don't seem to get getting how forking and virtual memory works.
Consider a process which uses two int/pointer sized memory locations. One contains a value, and the second contains a pointer to the first:
virtual value
address
0x10000 0x12345678
0x10008 0x10000
Those are virtual addresses - those are the addresses the process sees, and which are printed out in things like SCALAR(0x10000). The CPU's hardware behind the scenes maps that page of address space for that process to some physical page in RAM. This is all behind the scenes - you never get to see physical addresses. After the fork, the child process gets a *copy* of the parents address space - same virtual address locations, but mapping to a different physical page of memory which contains a copy of the values:
physical virtual value
address address
parent
0x2220000 0x10000 0x12345678
0x2220008 0x10008 0x10000
child
0x4440000 0x10000 0x12345678
0x4440008 0x10008 0x10000
After the child modifies the value, you get this:
parent
0x2220000 0x10000 0x12345678
0x2220008 0x10008 0x10000
child
0x4440000 0x10000 0xdeadbeef
0x4440008 0x10008 0x10000
There is absolutely no connection between the parent and child aside from the fact that initially the child's value in its memory is a copy of the parent's. If you think your code shows shows something else, please say which exact line of output shows this, and what you think its output should be.
Dave. |