Hardware Reference
In-Depth Information
process to the blocks belonging only to that process. Most forms of virtual memory also reduce
the time to start a program, since not all code and data need be in physical memory before a
program can begin.
Although protection provided by virtual memory is essential for current computers, sharing
is not the reason that virtual memory was invented. If a program became too large for physical
memory, it was the programmer's job to make it it. Programmers divided programs into
pieces, then identified the pieces that were mutually exclusive, and loaded or unloaded these
overlays under user program control during execution. The programmer ensured that the pro-
gram never tried to access more physical main memory than was in the computer, and that
the proper overlay was loaded at the proper time. As you can well imagine, this responsibility
eroded programmer productivity.
Virtual memory was invented to relieve programmers of this burden; it automatically main
ages the two levels of the memory hierarchy represented by main memory and secondary
storage. Figure B.19 shows the mapping of virtual memory to physical memory for a program
with four pages.
FIGURE B.19 The logical program in its contiguous virtual address space is shown on
the left . It consists of four pages, A, B, C, and D. The actual location of three of the blocks is
in physical main memory and the other is located on the disk.
In addition to sharing protected memory space and automatically managing the memory
hierarchy, virtual memory also simplifies loading the program for execution. Called relocation ,
this mechanism allows the same program to run in any location in physical memory. The pro-
gram in Figure B.19 can be placed anywhere in physical memory or disk just by changing the
mapping between them. (Prior to the popularity of virtual memory, processors would include
a relocation register just for that purpose.) An alternative to a hardware solution would be
software that changed all addresses in a program each time it was run.
 
Search WWH ::




Custom Search