Re: doubt regarding VMA

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

 



Dear Raj, everyone

I try to help....here it is.....CMIIW

>    I have a doubt regarding the working of the VMA. How is a program
> executable's text region shared among processes that are running the
> same program ? I would like to understand how finally the same pages
> are shared between the 2 processes .

Well, first of all, VMA structures are unique for each process. The 
exception is thread, which is sharing text region, global data segment 
(not the thread specific one). You must also notice, VMAs of different 
processes might map same page(s).

The only scenario I can think, when two or more processes share VMA of 
text region (pay attention, you are asking about VMA, not the page or 
page frame) are in multi threading. Since they execute same code (in 
most cases, new thread are created with clone() using CLONE_VM), it 
makes sense to share the text region for efficiency. Code region is 
something that is read only too, so sharing them won't hurt :)

Same pages (we are now talking about pages) can be mapped into different 
VMA of entirely different process, for example mmap()-ing shared 
libraries. Why it can happen? during file read, several pages landed 
into page cache. The pages on pages cache is always the first place to 
be looked up when reading a file, before directly fetching data block  
(if none is exist on page cache). So, successive read of the file 
(including mmap()) might just map the page into different VMA

Rik, Greg, everyone....feel free to CMIIW

regards

Mulyadi


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