Locality and Virtual Memory

by : Jesse Miller



The benefits of virtual memory are attractive. It has become an essential component of most contemporary operating systems.

Consider a larger process consisting of a long program plus a number of arrays of data. Over any short period, execution may be confined to a small section of the program and access to perhaps only one or two arrays of data.

It would clearly be wasteful to load in dozens of pieces for that process when only a few pieces will be used before the program is suspended and swapped out. Better use of memory can be obtained by loading in just a few pieces. If the program branches to an instruction or if it references a data item on a piece not in main memory, a fault is triggered. This tells the operating system to bring in the desired piece.

At any one time only a few pieces of any given process are in memory and therefore more process can be maintained in memory. Furthermore, time is saved because unused pieces are not swapped in and out of memory. The operating system must be clever about how it manages this scheme. In the steady state, practically all the main memory will be occupied with process pieces, so that the processor and operating system will have direct access to as many processes as possible. Thus, when the operating system brings one piece in, it must throw another out. If it throws out a piece just before it is about to be used, then it will just have to get that piece just before it is about to be used, then it will just have to get that piece again almost immediately. This leads to a condition known as thrashing. The processor spends most of its time swapping information pieces rather than executing user based command instructions. The avoidance of thrashing was a major research area in the 1970s and led to a variety of complex but effective algorithms. In essence, the operating system tries to guess, on the basis of recent history, which pieces are least likely to be used in the near future.

Quick Note: Taking the Nonsense out of looking for the right spyware remover

If you really want to take the work out of looking for that right Spyware Protection from a go to the Internet and get a or a Free
Download, In order to prevent your vital information from being ripped from your computer get your Remover Today.

The foregoing reasoning is based on belief in the principle of locality. The principle of locality states that program and data references within a process tend to cluster. The assumption that only a few pieces of a process will be needed over a short period is valid.