Memory mapping is the translation between the logical address space and the physical memory. The objectives of memory mapping are (1) to translate from logical to physical address, (2) to aid in memory protection (q.v.), and (3) to enable better management of memory resources. Mapping is important to computer performance, both locally (how long it takes to execute an instruction) and globally (how long it takes to run a set of programs). In effect, each time a program presents a logical memory address and requests that the corresponding memory word be accessed, the mapping mechanism must translate that address into an appropriate physical memory location. The simpler this translation, the lower the implementation cost and the higher the performance of the individual memory reference.
There are two fundamental situations to be handled. When the logical address space is smaller than the physical address space (common to micro controllers, microprocessors, and older mini- and mainframe computers, mapping is needed to gain access to all of physical memory). When the logical address space is larger than the physical address space, mapping is used to insure that each logical address generated corresponds to an existing physical memory cell.
The size of the logical address space is determined by the number of bits in a memory address. Typically, the size of an address is limited by the word length of the computer. On a typical 1980s vintage computer with a 16-bit word, only 216 or about 65000 words could be addressed. Technology now permits such systems to be attached physically to many times this memory, but there is no direct way to address it without redesigning the instruction set. Thus, the primary purpose of a memory mapping mechanism on such a system is to enable the logical address space to be assigned to a desired portion of a larger physical address space. In paging, the logical address space is divided into a set of equal-sized blocks called pages, and each is mapped onto a block of physical memory called a page frame. Each page must begin at a page frame boundary in physical memory. The primary advantage of paging is that it allows a contiguous logical address space to be split into several non contiguous physical frames. This permits sharing of some of a program’s pages among multiple processes without complete overlap of physical addresses. The page map file is often kept in a cache memory.
Segmenting breaks the logical address space into several blocks, but does not require them to be of any particular size or to be mapped into any particular physical frames. Physical addresses are obtained by biasing the individual segments. This approach is the most flexible but also the most costly, both in hardware and performance. It requires both a segment table and an extra addition operation per memory reference.