Section 12.2: Virtual Memory in Action (Frame 2)                     [prev][home][next]

Pages (and frames) range from 512 bytes up to 8K, with 1K, 2K and 4K being most common. There are problems when pages are too small or too large so a suitable balance must be struck, often by running a large number of real programs and watching how the patterns of addresses to determine if there is too much swapping.

Fig. 12.2.2 shows the program of Fig. 12.2.1 executing in several stages. The entire program is placed on disk initially. When the OS begins to execute it, one page is loaded into memory, the page containing the beginning of the main() function, called the program's entry point. If page 0 contains the entry point, page 0 would be loaded first. Over time, pages 1, 6 and 4 are referenced, so they are copied into frames. The data in frame 6 is then modified.


Fig. 12.2.2: Program beginning to execute.