Shared Data/Code object creation

Shared Data/Code object creation

Post by Rudy Klinksie » Fri, 21 Jan 2000 04:00:00



Hello:

        Is it possible under Solaris 2.x to build a shared "entity"
        ( using C) having the following features:

        1) global variables in this shared object would be readable
           AND writable by executables linked to this shared "entity"
        2) after all executables that use this shared object had
           completed, the current values (in memory) of the globals
           would be written back to disk.
        3) it would be nice to have a "main()" in this shared "entity"
           ( making it an executable itself ) for initialization
           purposes
        4) I am assuming that any functions in this shared entity
           would still be sharable amoung the executable pgms
           linked to this shared "entity"

        These features would allow you to have the following
        functionality:

        1) running the main() shared "entity" would initialize the
           global data
        2) global variables would retain their last values across
           pgm invocations.
        3) A second pgm, pgm2, would be able to "see" changes that
           another pgm, pgm1 had made.

        I am NOT looking for an ipc (Solaris shared memory) option.

        A shared file option would give the same effect..., except
        this is also not what I am looking for. This option imposes
        pointers/handles for programming purposes.

        I want the linker to do ALL the work for me, in the sense
        that if I had a global variable A in the shared entity, I
        could simply reference A in pgm.c, and NOT have to use a
        pointer/handle to A in the mmapped file case.

        This really boils down to a question of how to manipulate
        the linker to produce the desired results. It appears that
        shared objects linked under Solaris, when you write to them,
        the pgm gets its own copy of the segment. The linker needs
        to be told not to do this, and flush any changes back to disk.

        As an aside, under VMS and Fortran, you could create an
        executable shared data/code object, and link it into other
        pgms, and have the features that are mentioned in items
        1) thru 4).

        Any help or suggestions would be appreciated.

        Thanks,
        klink