megabyte@chinet.UUCP (Mark E. Sunderlin) (06/16/86)
My SYSIII machine has a -i option to its ld(1) command. It is described as such: -i Seperate the program text and data areas when the output file is executed. Text occupies segement 0; its origin is 0x0000. Data and bss occupy segement 1;data's origin is 0x0000. Bss follows data. I am unsuure as to the exact effects of this option. If I understand it, when my program runs it is in memory as such: _______________________ | program code | / \ Lower addresses ----------------------- | | program data | | ----------------------- \ / Higher addresses As opposed to having the program instructions and data mixed in among each other. I have a friend who says this is true and it is done so that two people running the same program can share text segments and each have its own data area. This saving memory and time. Could some one explain the -i option to me. I don't even see it in my SYSV documentation. Also, does UN*X keep only one copy of a program in memory, even if two or more people are running it? If it means anything , I am running on a Zilog S8000 wih ZEUS 3.21 which is a sysIII port. -- _________________________________________________________________________ UUCP: (1) seismo!dolqci!irsdcp!scsnet!sunder Mark E. Sunderlin (2) ihnp4!chinet!megabyte aka Dr. Megabyte CIS: 74026,3235 (202) 634-2529 Quote: "You have to have FAITH, for that to work on me!" Mail: IRS 1111 Constitution Ave. NW PM:PFR:D:NO Washington, DC 20224
terryl@tekcrl.UUCP (06/26/86)
In article <374@chinet.UUCP>, megabyte@chinet.UUCP (Mark E. Sunderlin) writes: > > My SYSIII machine has a -i option to its ld(1) command. It is described > as such: > -i Seperate the program text and data areas when the output file is > executed. Text occupies segement 0; its origin is 0x0000. Data and bss > occupy segement 1;data's origin is 0x0000. Bss follows data. > > I am unsuure as to the exact effects of this option. If I understand it, > when my program runs it is in memory as such: > > _______________________ > | program code | / \ Lower addresses > ----------------------- | > | program data | | > ----------------------- \ / Higher addresses > > As opposed to having the program instructions and data mixed in among each > other. I have a friend who says this is true and it is done so that two > people running the same program can share text segments and each have its > own data area. This saving memory and time. > > Could some one explain the -i option to me. I don't even see it in my SYSV > documentation. Also, does UN*X keep only one copy of a program in memory, > even if two or more people are running it? > > If it means anything , I am running on a Zilog S8000 wih ZEUS 3.21 which is a > sysIII port. Well, I don't know anything about a Zilog S8000, but if it's anything like a PDP, that I know about. On a PDP, there are two sets of memory manage- ment registers for each mode the processor may be in, system mode (which is what the operating system runs in), and user mode (which, suprise!!! is what user programs run in). On a PDP, there are eight registers in each set, and each register can map a maximum of 8 k-bytes of VIRTUAL address space. Memory references are classified into two classes: program (or instruction) references, and data references. Depending on what kind of reference the processor is making (either instruction or data) will choose which of the two sets of memory management registers to use. Now to the -i flag to the loader. When you specify the -i option to the loader, the program instructions and data are NOT really mixed in among each other, even though it may look like that. What you have to remember is that a program running in VIRTUAL space actually has two address spaces to access: instruction space, and data space. Each space is separate (hence the name separate I/D) and independent of one another. It is up to the loader to link the file correctly with the correct address in either instruction space or data space, so the program can run correctly. It is then up to the opera- ting system to set up both sets of memory management registers (at least on the PDP) correctly so the program can run. As to the question of UN*X keeping only one copy of the program in memory, it all depends on how the program was created. In the -i case, yes it is true that only one copy of the program is in memory, even if more than one person is running it, and each instance of that running program has its own private copy of the data. I don't know about the Zilog, but on the PDP at least, there was another option to the loader: the -n option. This told the loader to link the program as shared text, but instead of making the program separate I/D, just relocate the data starting at the next 8 k-byte boundary after the text. The 8 k-byte is a magic number for the PDP due to its memory management hardware (on the VAX under 4.2 it is 1 k-byte). As with the -i option, with the -n option to the loader, there is still only one copy of the program in memory, and each instance of that running program had its own private copy of the data. Hope this helps!!!! Terry Laskodi of Tektronix