Expert C Programming

(Jeff_L) #1

It is very inconvenient for a program to be restricted by the amount of main memory installed on a
machine, as happens on MS-DOS. So early on in computing, the concept of virtual memory was
developed to remove this restriction. The basic idea is to use cheap but slow disk space to extend your
fast but expensive main memory. The regions of memory that are actually in use by a program at any
given instant are brought into physical memory. When regions of memory lie untouched for a while,
they are likely to be saved off to disk, making room to bring in other memory areas that are being used.
All modern computer system from the largest supercomputers to the smallest workstations, with the
sole exception of PC's, use virtual memory.


Moving unused parts out to disk used to be done manually by the programmer, back in the early days
of computing when snakes could walk. Programmers had to expend vast amounts of effort keeping
track of what was in memory at a given time, and rolling segments in and out as needed. Older
languages like COBOL still contain a large vocabulary of features for expressing this memory
overlaying—totally obsolete and inexplicable to the current generation of programmers.


Multilevel store is a familiar concept. We see it elsewhere on a computer (e.g., in registers vs. main
memory). In theory, every memory location could be a register. In practice, this would be
prohibitively expensive, so we trade off access speed for a cheaper implementation. Virtual memory
just extends this one stage further, using disk instead of main memory to hold the image of a running
process. So we have a continuum.


Handy Heuristic

Free download pdf