Encyclopedia > Virtual memory

  Article Content

Virtual memory

Virtual memory is a computer design feature that permits software to run in a memory address space whose size and addressing are not necessarily tied to the computer's physical memory. It was first invented at the University of Manchester for the Atlas Computer, completed in 1962.

Simplistically, when a memory location is read or written to, hardware within the computer translates the memory address generated by the software (the virtual memory address) into a, usually distinct, real memory address (the physical memory address) within the computer's memory. This is accomplished by preserving the low order bits of the binary representation of the input address while treating the high order bits as a key to one or more address translation tables. For this reason a range of consecutive addresses in the virtual address space whose size is a power of two will be translated in a corresponding range of consecutive physical addresses. The memory referenced by such a range is called a page. The page size is usually 512, 1024 or 2048 bytes, though page sizes as large as 32768 bytes have been known.

The translation is implemented by an MMU. This may be either a module of the CPU or an auxiliary, closely coupled chip. The MMU may have the ability to monitor page references according to the type of reference (for read, write or execution) and the privilege mode of the CPU at the time the reference was generated. In addition, the MMU may detect that a reference is to a page that is marked as unavailable. The MMU responds to such conditions by raising an exception with the CPU which will be trapped by system software. This makes it possible for an operating system to carry out swapping. This is the behaviour of copying one page of memory to disk in order to restore to memory another page copied to disk earlier.

The most fundamental advantage of virtual memory is that it allows a computer to multiplex its CPU and memory between multiple programs without the need to perform expensive copying of the programs' memory images. It also allows the operating system to protect its own code from corruption by an erroneous application program and to protect application programs from each other and (to some extent) from themselves. If the combination of virtual memory system and operating system supports swapping, then the computer may be able to run simultaneously programs whose total size exceeds the available physical memory. This is possible because most programs have a small subset (active set) of pages that they reference over significant periods their execution. If too many programs are run at once, then copies to and from disk will become excessively frequent and overall system performance will become unacceptably slow. This is called thrashing and corresponds to access to the swap medium being three orders of magnitude or more slower than access to main memory.

Note that virtual memory is not a requirement for precompilation of software, even if the software is to be executed on a multiprogramming system. Precompiled software may loaded by the operating system which has the opportunity to carry out address relocation at load time. This suffers by comparison with virtual memory in that a copy of program relocated at load time cannot run at a distinct address once it has started execution.

In embedded systems, swapping is typically not supported—virtual memory is primarily a convenience to cope with software errors.

See also: CPU design, computer, memory management



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Radio programming

... shows being traded and collected in reel-to-reel, cassette and MP3 format. In the late 1940s and early 1950s, the advent of television gradually eroded the ...