Open VMS Operating System Concepts, Second Edition

When the working set is too small, page faults will occur more often than necessary. This phenomenon is called thrashing. Allocating too many frames to the working set of a process wastes the memory resource, depriving other processes of physical memory. Allocating too few frames forces the image to page fault unnecessarily. If the number of frames a process is allowed to use is restricted, whenever a new frame is faulted, memory management will have to remove a page from the working set to make room for the new one. But if the removed page is actually part of the working set, another page fault will occur when that page is referenced again, driving still another page of the working set out. In this situation, the page fault rate causes unnecessary system overhead, and system performance will suffer.
Figure 4.14 illustrates a two-dimensional array that exactly fills two pages. The first row is stored in one page, and the second row is stored in the other.
The program merely clears every element of the array. For simplicity, assume that the code is entirely contained on a third page. There are two ways to write this program. In Figure 4.14a, all the columns in the first row can be zeroed and then all the columns in the second row can be zeroed too. This solution has two pages in its working set. (A typical working set size is much larger than two pages. This working...