Hardware Reference
In-Depth Information
physical address is. We presume that there is enough room on disk to store the en-
tire virtual address space (or at least that portion of it that is being used).
Programs are written just as though there were enough main memory for the
whole virtual address space, even though that is not the case. Programs may load
from, or store into, any word in the virtual address space, or branch to any instruc-
tion located anywhere within the virtual address space, without regard to the fact
that there really is not enough physical memory. In fact, the programmer can write
programs without even being aware that virtual memory exists. The computer just
looks as if it has a big memory.
This point is crucial and will be contrasted later with segmentation, where the
programmer must be aware of the existence of segments. To emphasize it once
more, paging gives the programmer the illusion of a large, continuous, linear main
memory, the same size as the virtual address space. In reality, the main memory
available may be smaller (or larger) than the virtual address space. The simulation
of this large main memory by paging cannot be detected by the program (except by
running timing tests). Whenever an address is referenced, the proper instruction or
data word appears to be present. Because the programmer can program as though
paging did not exist, the paging mechanism is said to be transparent .
The idea that a programmer may use some nonexistent feature without being
concerned with how it works is not new to us, after all. The ISA-level instruction
set often includes a MUL instruction, even though the underlying microarchitecture
does not have a multiplication device in the hardware. The illusion that the ma-
chine can multiply is typically sustained by microcode. Similarly, the virtual ma-
chine provided by the operating system can provide the illusion that all the virtual
addresses are backed up by real memory, even though this is not true. Only operat-
ing system writers (and students of operating systems) have to know how the illu-
sion is supported.
6.1.2 Implementation of Paging
One essential requirement for a virtual memory is a disk on which to keep the
whole program and all the data. The disk could be a rotating hard disk or a solid-
state disk. Throughout the rest of this topic we will refer to ''disk'' or ''hard disk''
for simplicity, but understand that this includes solid-state disks as well. It is con-
ceptually simpler if one thinks of the copy of the program on the disk as the origi-
nal one and the pieces brought into main memory every now and then as copies
rather than the other way around. Naturally, it is important to keep the original up
to date. When changes are made to the copy in main memory, they should also be
reflected in the original (eventually).
The virtual address space is broken up into a number of equal-sized pages.
Page sizes ranging from 512 to 64 KB per page are common at present, although
sizes as large as 4 MB are used occasionally. The page size is always a power of 2,
for example, 2 k , so that all the addresses can be represented in k bits. The physical
 
 
Search WWH ::




Custom Search