Sharing data from a library (Solaris 2.4)

Sharing data from a library (Solaris 2.4)

Post by Tonnes Ingebrigtse » Sat, 11 Feb 1995 03:59:57



I need to put some datastructures into a shared library, and have
programs linking with it share the data for real
This is trivial, as long as these structures don't contain any
pointers.

Build this into a library:

struct s1{
        int i,j;
        int pad[1<<20];

Quote:};

struct s2{
        int i;
        const struct s1 * ss1p;

Quote:};

const struct s1 s1var={
        1,2,{1}

Quote:};

const struct s2 s2var={
        1,
        &s1var,

Quote:};

Make a program that access the s2var from the library, and instances
of the program will actually share the data. That is, they will share
s1var, and hold s2var in private pages. (If you do change s2
to contain a lot of data istelf, you will see the size required by the
running processes increase.)

struct s2{
        int i;
        const struct s1 * ss1p;
        int pad[1<<20];

Quote:};

This indicates to me that I'm unable to make the structures containing
poiters truly shared. Am I right, or is there a way around it?

I'm running Solaris 2.4, cc: SC3.0.1

The Makefile:

use_bar: libbar.so use_bar.c
        cc -xstrconst -R. -L. use_bar.c -o use_bar -lbar

libbar.so: bar.c
        cc  -xstrconst -c -K PIC bar.c
        cc  -xstrconst -G -z text -o libbar.so bar.o

Thanks

Tonnes Ingebrigtsen
Consultant
Skrivervik Data AS
Norway

 
 
 

1. Shared Libraries with global C++ objects under Solaris 2.4

Can anybody tell me how to build a shared library that contains global
objects (C++) under Solaris 2.4. The problem I have is that the constructor
for these objects is never called. Under SunOS 4.1.x I put the global
objects into a lib.sa file but .sa files are no longer supported by Solaris 2.4.

I tried both CenterLine and SparcCompiler 4.0, but none of them generated
code to cope with the initialization of the global objects.

        Thank you

                Wolfgang

--

Siemens AG, ZFE T SE 2    
81730 Muenchen / Germany   Phone:    +49 89 63649492
Otto Hahn Ring 6           Fax:      +49 89 63640898

2. Audio & threads

3. BIND shared libraries on Solaris 2.4

4. RTL8029 on Solaris cont.

5. Shared data in shared library

6. X shutdown after a couple of hours

7. Sharing Data in Shared Libraries

8. 'append' without LILO or loadlin?

9. Global data sharing in shared libraries

10. Shared data in a shared library?

11. Q: possible to share DATA by shared library

12. Shared Libraries and Caching under Sol 2.4 on HyperSparc

13. Solaris 10: Increasing the process data space; shared memory segments & intimate shared memory problems