Obviously, we have a code block like
int main() { pid_t pid; int y = 3; if ( (pid = fork()) <0 ) return -1;; if( pid == 0 ) { printf(" before: %d %p\n", y, &y ); y *= 10; printf("after: %d %p\n", y, &y ); } else { sleep(1); printf("father: %d %p\n" , y , &y ); } return 0; }
The printable address is the same for each printf (), and the previous post in this section assumes that it is due to virtual memory. But my confusion is that this means that each parent and child have a separate physical address space, and if so, then why the virtual address cannot be different, because ultimately it will be mapped to the corresponding physical address space using the MMU .
source share