Basic Fork Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Process A has a memory allocated and memory pointer x pointing to that memory.
I fork process B from a running process A.B gets a new copy of the
memory and the pointer.However, printing x in A and B points to the
same memory location(though actually differnt physical memory
locations).What is the concept of VM here.Can anyone kindly explain ?

=======================
For eg. :

[root@XXXXX]# cat test.c
#include <stdio.h>

main ()
{
        char a;
        a='b';
        fork();
        a='c';
        printf ("%x\n",&a);
}


[root@XXXXXX]# ./a.out
bfed3237
bfed3237

Thanks,
Link

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux