This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Shared library loading, please help me


matteo.pampolini@seleniacomms.com writes:

> just a stupid question: I noticed that the _init() function of a shared
> library is called every time
> an app that uses the library is launched, even though the library was
> already loaded in memory.
> 
> Then, if I have a shared library that must perform some hardware
> initialization only once, how
> can I check this for example with an "initialized" variable? Because I
> verified that every time I
> load the library the variable is set to its default value.

You have some misconception about Unix processes.  Every Unix process
executes in a separate memory space.  The fact that a shared library
was initialized in one memory space means nothing to another process
in another memory space.

If you want to do hardware initialization in a shared library, and you
want to do it only once, then you need to use some sort of IPC
mechanism, such as semaphores, a server process, a file system lock,
etc.  This is a general Unix programming question, not a binutils
question.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]