From: utzoo!decvax!harpo!eagle!mhuxt!mhuxa!mhuxh!mhuxm!pyuxjj!pyuxll!jse Newsgroups: net.unix.-wizards Title: shared subroutines for unix? Article-I.D.: pyuxll.260 Posted: Tue Aug 10 10:16:01 1982 Received: Thu Aug 12 05:44:18 1982 I am wondering if anyone has ever tried to implement some sort of mechanism to share a single copy of common subroutines amoung processes in unix. Such a thing would offer the ability to use rather large libraries in many processes of a real-time system without a tremendous swapping overhead (I'm talking about usg unix). On the vax with usg unix 4.0 or 5.0, it should be possible to place common routines in regular shared memory, or to make some pages of the system region readable and place the routines there. The problem then becomes one of linkage: how does the non-shared code reference the shared code, and how does the shared code reference anything that is not on the stack? The non-shared code could call a shared routine via a pointer to a function, but the shared code must reference globals and statics at fixed addresses. The only solutions I can think of are to change the shared code to avoid globals and statics, or to place a table of pointers to certain globals and statics at a certain fixed address of non-shared text (say, near zero), and let the shared code reference these variables indirectly. Another related question is whether or not the C compiler generates position independent code (I haven't had time to try to figure out for myself). This would be important if the shared routines were to be placed in regular shared memory. I believe that such schemes have been used before on other operating systems (e.g. mert, vax/vms), but I have never heard of anyone being interested in doing it for unix. Is there some relevant issue that I am missing? I would also be interested in hearing from anyone who has experience using such a facility (e.g. to tell me that it is a good or bad idea). Thanks in advance, Jan Edler ..!pyuxjj!pyuxll!jse (btl piscataway) ..!cmcl2!edler (nyu)