[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Somethings about libraries..

On Fri, Nov 17, 2000 at 12:55:17PM +0530, Kedar Patankar wrote:
> In case of shared libraries, its correct. Only one copy of the shared
> library code exists in the core at any time. But about apps, I am not
> sure whether if all the instances of bash running on a box share the same
> code "segment". If an app forks then yes, the children would share the
> same code area, but I doubt if two unrelated instances of the same
> executable share the same code area.

The two copies of bash will have different code segments (vm_area in
linux kernel lingo). However, the code segments don't store anything.
They just have references to pages, which are instantiated on demand.

There is a lower level data structure called the vnode cache and this
data structure is global (across CPUs in a SMP system).

Suppose your bash executable was a 40k image = 10 pages on a x86,
there would be 10 pages in the vnode cache (bash:1, bash:2... bash:10).
The two code segments will be pointing to the same set of pages in the 
vnode cache.