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

Re: reentrantcy?



On Sat, Nov 19, 2011 at 07:03:19PM -0600, Paul Elliott wrote:
> 
> Is there any requirement that a shared library be reentrant, if the upstream 
> wrote it that way?
> 
> Am I correct in my assumption, that although non-reentrancy presents a problem 
> for multi threaded programs, it is not a problem for multi-programming, that 
> is two programs using the same shared library at the same time, because the 
> linker will assure that the separate programs will have separate copies of any 
> writable global or static data?

It's not the linker that does it, it's the kernel. Separate programs
have separate address space and can not influence each other over memory
unless they make the effort of setting up shared memory.

> I believe that it is better to write reentrant code and such code should be 
> written when starting from scratch. But there is no reason not to use already 
> existing non-reentrant code in non multi threaded applications. Am I correct?

There is also the case that a library can be used more than once without
threads, for example when you use the library in your program and
another library you link in also links to that library.

If all linkings are shared, it is my understanding that the global state
of the multiple-linked library would be shared by all references.

-- 
Andreas Bombe


Reply to: