Hardware Reference
In-Depth Information
technique, the register always points to the physical address of the start of the cur-
rent program. All memory addresses have the contents of the relocation register
added to them by the hardware before being sent to the memory. The entire reloca-
tion process is transparent to the user programs. They do not even know that it is
occurring. When a program is moved, the operating system must update the relo-
cation register. This mechanism is less general than paging because the entire pro-
gram must be moved as a unit (unless there are separate code and data relocation
registers, as on the Intel 8088, in which case it has to be moved as two units).
A third mechanism is possible on machines that can refer to memory relative
to the program counter. Many branch instructions are relative to the program
counter, which helps. Whenever a program is moved in main memory only the
program counter need be updated. A program, all of whose memory references are
either relative to the program counter or absolute (e.g., to I/O device registers at
absolute addresses) is said to be position independent . A position-independent
procedure can be placed anywhere within the virtual address space without the
need for relocation.
7.4.4 Dynamic Linking
The linking strategy discussed in Sec. 7.4.1 has the property that all procedures
that a program might call are linked before the program can begin execution. On a
computer with virtual memory, completing all linking before beginning execution
does not take advantage of the full capabilities of the virtual memory. Many pro-
grams have procedures that are called only under unusual circumstances. For ex-
ample, compilers have procedures for compiling rarely used statements, plus pro-
cedures for handling error conditions that seldom occur.
A more flexible way to link separately compiled procedures is to link each pro-
cedure at the time it is first called. This process is known as dynamic linking .It
was pioneered by MULTICS whose implementation is in some ways still unsurpas-
sed. In the next sections we will look at dynamic linking in several systems.
Dynamic Linking in MULTICS
In the MULTICS form of dynamic linking, associated with each program is a
segment, called the linkage segment , which contains one block of information for
each procedure that might be called. This block of information starts with a word
reserved for the virtual address of the procedure and it is followed by the procedure
name, which is stored as a character string.
When dynamic linking is being used, procedure calls in the source language
are translated into instructions that indirectly address the first word of the corres-
ponding linkage block, as shown in Fig. 7-17(a). The compiler fills this word with
either an invalid address or a special bit pattern that forces a trap.
 
 
Search WWH ::




Custom Search