Virtual memory
The operating system uses virtual memory to manage the memory
requirements of its processes by combining
physical memory
with secondary memory (
swap space)
on disk.
The swap area is usually located on a local disk drive.
Diskless systems use a page server to maintain their
swap areas on its local disk.
The amount of swap space is usually configured to be larger than physical memory; the sum of physical memory and swap space defines the total virtual memory that is available to the system.
Having swap space on disk means that the CPU's access to it is very much slower than to physical memory. Conventionally, the swap area uses an entire division on a hard disk. It is also possible to configure a regular file from within a filesystem for use as swap. Although this is intended for use by diskless workstations, a server can also increase its swap area in this way.
The swap area is used as an additional memory resource for processes which are too large for the available physical user memory. In this way, it is possible to run a process whose entire executable image will not fit into physical memory. However, a process does not have to be completely loaded into physical memory to run, and in most cases is unlikely to be completely loaded anyway.
The virtual address space of a process is divided into separate areas known as regions that it uses to hold its text, data, and stack pages. When a program is loaded, its data region consists of data pages that were initialized when the program was compiled. If the program creates uninitialized data (often known as bss for historical reasons) the kernel adds more pages of memory to the process' data region.
If the operating system is running low on physical memory, it can start to write pages of physical memory belonging to processes out to the swap area. See ``Paging'' and ``Swapping'' for more details.
Figure 4-1
illustrates how a process' virtual memory might correspond to
what exists in physical memory, on swap, and in the filesystem.
The
u-area
of a process consists of two 4KB pages
(displayed here as U

Figure 4-1 How the virtual memory of a process relates to physical memory and disk