Hardware Reference
In-Depth Information
Virtual address space
Free
Address space
allocated to the
call stack
Call stack
Currently used
Parse tree
Constant table
Source text
Symbol table
Figure 6-7. In a one-dimensional address space with growing tables, one table
may bump into another.
shuffling can be done, but it is analogous to managing one's own overlays—a nui-
sance at best and a great deal of tedious, unrewarding work at worst.
What is really needed is a way of freeing the programmer from having to man-
age the expanding and contracting tables, in the same way that virtual memory
eliminates the worry of organizing the program into overlays.
A straightforward solution is to provide many completely independent address
spaces, called segments . Each segment consists of a linear sequence of addresses,
from 0 to some maximum. The length of each segment may be anything from 0 to
the maximum allowed. Different segments may, and usually do, have different
lengths. Moreover, segment lengths may change during execution. The length of a
stack segment may be increased whenever something is pushed onto the stack and
decreased whenever something is popped off the stack.
Because each segment constitutes a separate address space, different segments
can grow or shrink independently, without affecting each other. If a stack in a cer-
tain segment needs more address space to grow, it can have it, because there is
nothing else in its address space to bump into. Of course, a segment can fill up
completely but segments are usually very large, so this occurrence is rare. To spec-
ify an address in this segmented or two-dimensional memory, the program must
supply a two-part address: a segment number, and an address within the segment.
Figure 6-8 illustrates a segmented memory being used for the compiler tables dis-
cussed earlier.
We emphasize that a segment is a logical entity, which the programmer is
aware of and uses as a single logical entity. A segment might contain a procedure,
or an array, or a stack, or a collection of scalar variables, but usually it does not
contain a mixture of different types.
 
 
Search WWH ::




Custom Search