Re: Dynamic linking library

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

 



ratheesh k wrote:

> Suppose there are two executable elf . say A, B . And these two are
> using  libctest.so.
> When A is executed  libctest.so is loaded into RAM

No, it is *mapped* into the process' address space (virtual memory). 
Data is loaded into physical RAM on demand by the kernel.

> and linear address is correctly mapped.
> 
> If we execute program B after A ,  will library will be loaded again ?

It will be mapped into B's address space.

> else, how OS know that libctest is already loaded into physical page ?
> (so it can  map linear address to it )

Mapping a file into a process' address space sets up structures within
the kernel recording the fact that specific pages of the process'
address space correspond to specific blocks of a specific device.

Initially, the MMU will consider those pages as unmapped, so accessing
those addresses will cause the CPU to generate an exception (page
fault). The kernel handles the exception by ensuring that the
appropriate disk block is loaded into physical RAM, updating the MMU
so that the virtual memory page is mapped to the appropriate physical
memory page, then restarting the instruction.

When cached blocks are discarded from physical RAM, any the MMU
mappings are removed so that a subsequent access will raise an
exception.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux