|
Home > Archive > Unix Programming > August 2004 > mapping of shared libraries
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
mapping of shared libraries
|
|
| j0mbolar 2004-08-22, 6:08 pm |
| I've read that shared libraries are mapped into memory and shared
amongst processes. If I have a program called "someapp" that uses a
library called
"foobar", and if I have eight instances of "someapp" running, then
they all
supposedly share "foobar". Which makes me wonder, this doesn't sound
right
because if I had a function in my library being shared which had a
static
buffer(say strtok for this example) then the individual processes
would
overwrite or share the data of the function in the shared library.
So if this isn't correct, how then, is the library actually shared
amongst many processes?
| |
| Jens.Toerring@physik.fu-berlin.de 2004-08-22, 6:08 pm |
| j0mbolar <j0mbolar@engineer.com> wrote:
> I've read that shared libraries are mapped into memory and shared amongst
> processes. If I have a program called "someapp" that uses a library called
> "foobar", and if I have eight instances of "someapp" running, then they all
> supposedly share "foobar". Which makes me wonder, this doesn't sound right
> because if I had a function in my library being shared which had a static
> buffer(say strtok for this example) then the individual processes would
> overwrite or share the data of the function in the shared library. So if
> this isn't correct, how then, is the library actually shared amongst many
> processes?
The text section (i.e. the code) of the libraries is shared between
processes using the library but not the data sections (e.g. static
buffers etc.), of this each process gets its own set.
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.toerring.de
| |
| bob holder 2004-08-22, 6:08 pm |
|
"j0mbolar" <j0mbolar@engineer.com> wrote in message
news:2d31a9f9.0408200658.238002d@posting.google.com...
> I've read that shared libraries are mapped into memory and shared
> amongst processes. If I have a program called "someapp" that uses a
> library called
> "foobar", and if I have eight instances of "someapp" running, then
> they all
> supposedly share "foobar". Which makes me wonder, this doesn't sound
> right
> because if I had a function in my library being shared which had a
> static
> buffer(say strtok for this example) then the individual processes
> would
> overwrite or share the data of the function in the shared library.
> So if this isn't correct, how then, is the library actually shared
> amongst many processes?
The text (code) segment of the shared library would be shared among the 8
someapp processes. The shared library's data segment would be COW and
unique.
bob
|
|
|
|
|