fork() and Copy On Write

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

 



Hello,
From all what I had read on the Linux Kernel I understand
that when we call fork() from an application then a new proess
is created, and its memory is copied from the process that
created it but it is now SHARED and READ-ONLY.

My architecture is Intel x86.

I had tried to locate where exactly in the sources this happens;
(namely , where is setting to SHARED and READ-ONLY made for the new process).


I had looked at kernel/fork.c in 2.4.20 (and also 2.6.7) kernel.

In 2.4.20,there is a method named do_fork(); what seems relevant to memory
copying seems to me the call inside to copy_mm() which calls dup_mm().

I had looke at the code of theses methods and could not find a code where
there is a setting to SHARED and READ-ONLY for the pages
of the memory for the new process; any idea?

I want to clarify one more thing: I assume that the memory of the old
process which called fork() remains with the same privileges as it was before calling fork
(Namely , if it was R/W before fork() it will stay R/W also after fork()).


Regards,
Sting

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



-- 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