dave@dptechno.uucp (Dave Lee) (07/25/90)
System Info: HP-UX 7.0 -- HP9000/300 series (340,345,350,360) After reading the manual several times, under cc(1) , ld(1) , chatr(1) and others, I am very confused about the distinction of Shared and Demand Load. The chatr(1) man page implies that Shared and Demand load are mutually exclusive, ie. you can go from Shared to Demand load and back, but you cant turn on or off Shared and Demand load independantly. The cc(1) and ld(1) have different options for Shared (-n and -N) and Demand load (-q and -Q). This gets even more confusing when adding the sticky bit. My own limited performance analasis has proved inconclusive. My questions are: 1) If I want shared text among multiple processes running the same a.out file can I use "Demand Load" model ? 2) Does the sticky bit do anything for "Demand Load" executables ? I have a large X program (size= 1785024 + 58636 + 415476 = 2259136). This program may be running multiple coppies on the same system. However only about 10% of the program is used at any one time. I would like to have it Demand Load AND Shared. Startup is atleast 3 times as fast with demand load then shared. However, if I make the program shared and sticky, the startup time approaches demand load time for the 2nd startup. However, I would prefer not to use the sticky bit. Is Demand load AND Shared possible? I cannot find any diffinitive answer either way. Would anyone who knows what's going on here Please let me know. Email or post. Thanks a lot -- Dave Lee uunet!dptechno!dave
piet@cs.ruu.nl (Piet van Oostrum) (07/25/90)
In article <543@dptechno.UUCP>, dave@dptechno (Dave Lee) writes: | |Is Demand load AND Shared possible? |I cannot find any diffinitive answer either way. Would anyone who |knows what's going on here Please let me know. Email or post. Demand load implies shared -- see a.out(4) -- Piet van Oostrum <piet@cs.ruu.nl>
mjs@hpfcso.HP.COM (Marc Sabatella) (07/25/90)
>After reading the manual several times, under cc(1) , ld(1) , chatr(1) and >others, I am very confused about the distinction of Shared and Demand Load. This now officially qualifies as one of the Most Frequently Asked Questions. As far as chatr(1) and (ld) are concerned, "shared" and "demand load" are mutually exclusive - all their respective options do is set the magic number on the file to either SHARE_MAGIC or DEMAND_MAGIC (EXEC_MAGIC if you use -N). Well, not quite - they also know that SHARE_MAGIC and DEMAND_MAGIC data segment start addresses must be aligned on a page boundary, and that DEMAND_MAGIC text segments must be aligned within the file on a page boundary. Given that, though, it is up to exec(2) to decide whether to actually share or demand load the thing. Sharing requires read only text, which is why the data segment addresses start on the next page. Demand loading requires page alignment in the file itself. So as it happens, SHARE_MAGIC files are candidates for sharing, but not for demand loading; DEMAND_MAGIC files are candidates for both. And in fact, exec(2) will do exactly that - it will share SHARE_MAGIC and DEMAND_MAGIC files, and will demand load DEMAND_MAGIC files. While there is no technical reason you couldn't have a file which was demand loaded but not shared, there is no magic number which tells exec(2) to do that, so you can't. >My questions are: > >1) If I want shared text among multiple processes running the same > a.out file can I use "Demand Load" model ? As explained above, yes. >2) Does the sticky bit do anything for "Demand Load" executables ? Don't know. -------------- Marc Sabatella (marc@hpmonk.fc.hp.com) Disclaimers: 2 + 2 = 3, for suitably small values of 2 Bill and Dave may not always agree with me
cary@hpclcac.HP.COM (Cary Coutant) (07/26/90)
A demand-loadable file is always sharable also. Thus, there are only three valid combinations: non-sharable, non-demand-loadable (-N) sharable, non-demand-loadable (-n) sharable, demand-loadable (-q) Specifying both -n and -q is merely redundant, since you would be asking for sharable and demand-loadable, so -q alone would be equivalent. Specifying -N and -q would be a conflict, and I'm not sure which one would have precedence on the s300 (on the s800, -N overrides -q). On the s300, in the absence of any -n/-N or -q/-Q options, the linker will automatically decide between non-demand-loadable and demand-loadable, based on the size of the text. Thus, it might make sense to specify -Q if you wanted to force a program to be non-demand-loadable. On the s800, the default is always sharable, non-demand-loadable. Non-sharable programs are not supported on the 800, so the -N option is useful only for preparing things like kernels, boot images, and dynamic load images (in conjunction with ld -A). I believe the sticky bit is effective for sharable programs of both flavors. Cary Coutant HP California Language Lab Series 800 Linker Project