title: Code segment sharing between two processes
body: <p>Suppose we run two processes back to back say :-</p>
  
  <pre><code>$ grep abc abc.txt ==&gt; pid 100
  $ grep def def.txt ==&gt; pid 101
  </code></pre>
  
  <p>I read in the book "Beginning Linux programming" chapter# 11 that the code section of the processes would be shared, as it is read only. Is it so? I think if grep is compiled as shared library only then the code section would be shared.</p>
  
  <p>One more question, in case of shared libraries how does the OS knows that the library has already been loaded or not? Suppose if 2 processes are simultaneously calling a shared library function then how does the virtual address of two processes be converted to physical address pointing the same location in RAM?</p>