garyd@chemabs (garyd) (12/14/84)
Does anyone have any information on techniques of sharing code between processes in UNIX System V? I am aware of the work done by Bunker Ramo in "shared libraries" but I am looking for other sources of design ideas or implementations. Shared code involves allocating a chunk of shared memory and filling it up with executable code (which probably needs to be relocated). This region can then be attached by one or more processes which will then be able to call the functions within it. This results in a savings of physical memory, important when there are many processes that need to use the code and the code is large. (The intended code will be network interface code) I tried an experiment (under UNIX System III) which involved allocating a chunk of memory (malloc), and then, using the address returned, executed the loader (ld) using an undocumented flag (-B addr) to relocate the module (previously built using ld -r). The resulting a.out was copied to the region and called at addr+32 (skip over the header). This worked but there will be other problems when shared memory is involved (like the bss segment). If you know of any sources of information or if you have any thoughts on this capability, please reply. Thank you! Gary A. Davis Chemical Abstracts Service UUCP: ..{ihnp4|mhuxl|ho95b|ulysses}!cbosgd!osu-eddie!apr!chemabs!garyd AT&T: (614) 421-3600 X2355 USPS: Chemical Abstracts Service P.O. Box 3012 Columbus, Ohio 43210
padpowell@wateng.UUCP (PAD Powell) (12/15/84)
There is a very easy way to do dynamic loading under UNIX, using documented features of LD, a.out, etc. However, it depends on knowing the full pathname of the executing program, or being able to guess it in a fairly reliable manner. I have posted code to do this to the net.sources several times. I sure wish that there was a system call that would return the full path name of the text file of a process. Perhaps there is? Any kobolds know of any? Patrick Powell
ron@brl-tgr.ARPA (12/19/84)
> > Does anyone have any information on techniques of sharing code between > > processes in UNIX System V? > > This puzzles me. The obvious way to share code is to make a separate > process out of that code. ld -n and -i format code IS shared. I think what he is after is shared libraries. Even though shared text segments occurs in most UNICES, many programs contain a substantial number of library routines that are common to programs that are not loaded from the same disk file. Other operating systems have provision to keep library routines in memory so only one copy exists even though their may be many different programs using them. -Ron