[Prev][Next][Index]
Re: BEHAVIOR OF FUNCTIONS OF DLL AND DYNAMICLY LOADED LIB
In message <3ACB0A71@hagiga.jct.ac.il> you write:
|Shalom,
|
|
|I have some questions about functions belonging to a shared library.
|
|1. if a function foo(), from a shared library dynamicly loaded via
|'dlopen', declare one of its variable as static, what will happen to
|this statis variable if 2, or more, running processes call foo() ?
|
|Is this static variable will be still static relative to each process ?
Again, the sharing is only for the "text" (i.e. the code) pages. The
data is private for each process.
|
|2. if foo() call fork(), is the parent of the spawned child, the caller
|of foo2() ? What's happen if 2 or more running processes call foo() ?
question unclear. what I can say quite for sure is that libc, which
is where fork(2) is implemented, is usually a shared library these
days. it shouldn't matter to anyone if the code which created the
syscall trap is in a shared page or not.
|
|3. is a function from a shared lib dynamicly loaded (with dlopen)
|operate _only_ in the address space of the calling process.
yes.
I'd expect dlopen() will cause the loaded code to be sharable among
threads of the same process, but I'm not 100% sure about Linux'
implementation of threads.
|I would try this myself if I had an ELF system, but I have not :-(.
as far as I'm aware, the questions above are not affected from the
format of the binaries on the system. The answers too.
--Amos
--Amos Shapira | "Of course Australia was marked for
133 Shlomo Ben-Yosef st. | glory, for its people had been chosen
Jerusalem 93 805 | by the finest judges in England."
ISRAEL amoss@cs.huji.ac.il | -- Anonymous