What is Virtual Memory and what are Page Faults?

From BOINC Wiki
Revision as of 02:42, 22 May 2016 by Bowtieguru (talk | contribs)
Jump to: navigation, search

What is Virtual Memory?

A program instruction on an Intel 386 or later CPU can address up to 4GB of memory, using its full 32 bits. This is normally far more than the RAM of the machine. (The 32nd exponent of 2 is exactly 4,294,967,296, or 4 GB. 32 binary digits allow the representation of 4,294,967,296 numbers - counting 0.)

So the hardware provides for programs to operate in terms of as much as they wish of this full 4GB space as Virtual Memory, those parts of the program and data which are currently active being loaded into Physical Random Access Memory (RAM).

The processor itself then translates ("maps") the virtual addresses from an instruction into the correct physical equivalents, doing this on the fly as the instruction is executed. The processor manages the mapping in terms of pages of 4 Kilobytes each - a size that has implications for managing virtual memory by the system.


What are Page Faults?

Only those parts of the program and data that are currently in active use need to be held in physical RAM. Other parts are then held in a swap file (as it's called in Windows 95/98/ME: Win386.swp) or page file (in Windows NT versions including Windows 2000 and XP: pagefile.sys).

When a program tries to access some address that is not currently available in physical RAM, it generates an interrupt, called a Page Fault. This asks the system to retrieve the 4 KB page containing the address from the page file (or in the case of code possibly from the original program file). This - a valid page fault - normally happens quite invisibly. Sometimes, through program or hardware error, the page is not there either. The system then has an "Invalid Page Fault" error. This will be a fatal error if detected in a program: if it is seen within the system itself (perhaps because a program sent it a bad request to do something), it may manifest itself as a "blue screen" failure with a STOP error, look at this page on STOP Errors (I couldn't find it on the MSDN site anymore.)

If there is pressure on space in RAM, then parts of code and data that are not currently needed can be "paged out" in order to make room - the page file can thus be seen as an overflow area to make the RAM behave as if it were larger than it is.

| Jorden
| 6
| 1
| 12:49:22
| 2008-05-21
| 80530
| 1
| 351
| 2008-05-21 12:49:22
| 2008-05-21 12:49:22

|-