It is currently Wed, 22 May 2013 19:03:27 GMT



 
Author Message
 Using a shared lib as shared memory: Possible?
The question I'm about to ask was asked on comp.unix.programmer some time
back, in a slightly different context, by sort of a newbie type - who didn't
really understand what a shared lib is - but the thing is, I can't quite
remember what the outcome/resolution of that thread was.  So, I'm going to
ask it again...

My assumption is that if a shared lib is pure code, then all of the
currently running applications which are using that lib, are using the same
copy of it - i.e., that it is allocated space in (global/system-wide) memory
and everybody runs the same code when calling functions in the lib.
However, if there is static data in the lib, then a fresh copy of the static
data gets allocated for each caller.  And this is as it should be, since
otherwise, there would be chaos.

However, my question is, is it possible, through some compiler or linker
switches (or any other settings), to override this - to make a lib such that
when one program changes a global/static variable in the lib, the other
programs see the change?

Platform is Solaris, although I'd like the solution to also be portable to
Linux (although this isn't critical).  Objective is simply convenience/not
having to mess around with shared memory or mmap().  I view this as a Q&D
way of getting shared memory.



 Wed, 01 Oct 2003 04:44:14 GMT   
 Using a shared lib as shared memory: Possible?

Short answer? No. That's not how shared objects work. You'll
have to use some explicit sharing mechanism.

HTH,
--ag
--
Artie Gold, Austin, TX  (finger the cs.utexas.edu account
for more info)
mailto:ag...@bga.com or mailto:ag...@cs.utexas.edu
--
Clone Bernie!



 Wed, 01 Oct 2003 06:45:35 GMT   
 Using a shared lib as shared memory: Possible?
In article <3AD7818F.84660...@bga.com>, Arthur H. Gold <ag...@bga.com> wrote:
...

OK, thx.



 Wed, 01 Oct 2003 06:52:55 GMT   
 
   [ 3 post ] 

Similar Threads

1. Make Shared Memory Block Memory-Resident Possible?

2. Diff between Shared Object & Shared Lib

3. Legality of sharing /usr/lib/*,/usr/share/*, etc files

4. Memory access between a program and a shared lib

5. Memory deallocation in a shared lib with Solaris 2.X

6. Q: possible to share DATA by shared library

7. ?SRC: Queue Mngr Lib for Shared Memory?

8. shared Memory in a dynamic lib

9. shared Memory in a dynamic lib


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software