It is currently Tue, 21 May 2013 08:50:58 GMT



 
Author Message
 Shared Library/Shared Memory

Hello,

        I would like to get advices on using Shared Library to achieve Shared
Memory between processes. For example, the sharing of data structures
inside the shared library by processes.

        Thanks a lot for your advice.

        Fred Xia

--
// Xia, Zeqing Fred, Software Engineer          |_____/ \/\
// Bridge Information Systems, Inc.             |____/|_/\_\
// 717 Office Parkway, St. Louis, MO 63141      |___/_|_  _/
// 314-(O)567-8339 (X)432-5391, f...@bridge.com |  /  |        \/ \



 Thu, 23 Jan 1997 03:58:54 GMT   
 Shared Library/Shared Memory

I would also like to know the compilation of building shared libs.
Especially, I would like to know if it is possible to use gcc to
construct shared libraries with any options.

Thanks.

Fred

--
// Xia, Zeqing Fred, Software Engineer          |_____/ \/\
// Bridge Information Systems, Inc.             |____/|_/\_\
// 717 Office Parkway, St. Louis, MO 63141      |___/_|_  _/
// 314-(O)567-8339 (X)432-5391, f...@bridge.com |  /  |        \/ \



 Thu, 23 Jan 1997 04:47:03 GMT   
 Shared Library/Shared Memory
The shared libraries are loaded to read-only text segments in memory
so there is little point in keeping shared data structures in shared
libraries.  At least they cannot be altered.

And yes, gcc can be used to compile position independent code that can
be built into a shared library.  Use gcc -fpic to do that.  I think
the way to actually construct the shared library from position
independent object files is system specific.  On SunOS it can be done
like this:

ld -o libfoo.so.X.Y -assert pure-text <pic .o files>

X is the major and Y the minor version number for the shared library.
The version numbers are checked by the dynamic loader before running a
program.  When you upgrade a shared library and only the minor version
changes, your programs still run, but you get a warning message.  When
the major version number of your library changes, it means an
incompatible change has occured and the loader refuses to run your
program.  See man ld.so for details.
--
<A HREF="http://www.cs.hut.fi/~sti/">Sami Tikka</A>
"Peace and Long Life."
"Live Long and Prosper."



 Sat, 25 Jan 1997 07:15:40 GMT   
 Shared Library/Shared Memory

Only the program text of shared libraries is actually shared. Each process
gets it's own copy of data areas (usually as copy-on-write pages). To share
data look at the mmap calls (man 2 mmap) or shared memory (man 2 shmop should
get you started on the manual pages).

Actually constructing the shared library is normally the job of the linker and
is somewhat system dependant so look at the man pages for ld, however on a Sun
running SunOS 4 you just say

   ld -o foo.so.x.y o1.o o2.o o3.o ....

where x and y are the major and minor version numbers of the libraries. The
individual objects must be compiled as "position independant" code. Later
versions of gcc can generate PIC (use the -fpic or -fPIC options) so it should
be possible.

--
Paul Flinders                   Mail: p...@delcam.co.uk
Delcam International PLC.       Tel:  +44 21 766 5544   Fax: +44 21 766 5511



 Sat, 25 Jan 1997 15:54:52 GMT   
 Shared Library/Shared Memory
: In article <320q1u$...@news.bridge.com>, Fred Xia <f...@Bridge.COM> wrote:
: >
: >  I would like to get advices on using Shared Library to achieve Shared
: >Memory between processes. For example, the sharing of data structures
: >inside the shared library by processes.

: Only the program text of shared libraries is actually shared. Each process
: gets it's own copy of data areas (usually as copy-on-write pages). To share
: data look at the mmap calls (man 2 mmap) or shared memory (man 2 shmop should
: get you started on the manual pages).

This I understand. However, I was under the impression that you didn't
necessarily need to build your exe with shareable libraries.  If for example
you created a file xyz.exe and multiple users were using this, is the text
area shared?  In some cases, (ie copy on write) would therefore the data
areas also be shared.

Thanks in advance?

Jon

--
+--------------------------------------------------------------------+
| Jon Machtynger(j...@ingres.com) Ph: 02-716 32 18 Fax: 02-725 46 50 |
| Excelsiorlaan 25,  B-1930 Zaventem,  Brussels                      |
+--------------------------------------------------------------------+
|  LINUX is not a .... dirty word.                                  |
+--------------------------------------------------------------------+



 Tue, 28 Jan 1997 23:43:55 GMT   
 
   [ 5 post ] 

Similar Threads

1. Solaris Shared Memory, Shared Libraries and Heap

2. Will strip(debug shared library) == nodebug shared library ?

3. Help with building shared libraries with dependencies on other shared libraries

4. Shared library loading shared library.

5. Need a Shared Library Guru: beyond simple shared library question

6. Question: Inclusion of shared libraries during linking of shared libraries


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