SYSTEM ARCHITECTURE

infrequently, a virtual memory system will per- form nearly as well as one with far more memory at a fraction of the cost. The key architectural features needed to efficiently support virtual memory are:

oA bit for each segment or page that tells the processor (or memory management unit) if the segment or page is "present" in memory or needs to be swapped in from disk.

oA trap or exception mechanism by which the processor can notify the operating system to swap in a not-present segment or page.

oRestartable instructions that enable the proces- sor to retry an instruction after the operating system has loaded the formerly not-present page into memory and marked it present.

The 80386 has all of these necessary facilities, plus others that improve the efficiency of virtual memory management. Both descriptors and page table entries have a Present bit, and therefore can be used as the basis of a virtual memory design. Swapping segments between memory and disk is a reasonable approach when

the segments are relatively small as they are in l6-bit architectures. When segments can be very large, as they can on the 80386, swapping pages is usually a more effective approach, due to the fixed size of pages. In a page-based system, the operating system allocates and frees memory in page-sized units called page frames; a page swapped in from disk will fit into any available frame. Because most 32-bit virtual memory systems are page-based, the remainder of this section describes the 80386's page-based virtual memory support.

In general, a page-based virtual memory operat- ing system transfers not-present pages from disk to page frames on demand, that is, when notified by the processor that an instruction refers to a not-present page. When the number offree page frames runs low, the operating system also transfers pages from page frames to disk, at- tempting to remove the pages that are least likely to be referenced in the near future. By trans- parently swapping pages between page frames and disk, the operating system gives application software the illusion of a physical memory that is as large as the swap area on the disk. The details of these operations are described below.

ATTRIBUTES

PRESENT ----------------------

 

,

RIGHTS --------------------

 

,

PRIVILEGE ------------------

,

 

ACCESSED --------------

l--~l

, I

 

:::.-D-EF-IN-E-D-)--------

I

 

PAGE ADDRESS

I I I I I I

Figure 3-7.Principal Page Table Entry Fields

3-9

Page 34
Image 34
Intel 80386 manual I I I