Page faults


What is a page fault? When a program tries to reference a memory location and the translation step done by the MMU indicates an error, the CPU is interrupted right in the middle of the instruction (since it can't finish). This is generally because there is no valid page in memory to reference. It is then the kernel's responsibility to decide whether this address really is valid (usually because a copy of the page does exist on disk somewhere). If so, it has to get that page loaded up and let the user program with the offending instruction try again. If the address really is bad ” the user program shouldn't even be trying to get at that location ” then the kernel will signal the program with a SIGSEGV, which normally kills the program. So, a page fault is a reference to data that is not in memory, but might still be valid because it could be loaded from disk. If the data can be found, this is a legitimate reference and the data has to be fetched . If the reference doesn't refer to any data (it's not in that process's address space), it's an illegal reference. Kernel software determines when a page fault is valid and when it is completely erroneous.

A page fault may also refer to a legal address (but one that is not set up in the MMU), and the desired data is already loaded in memory because somebody else needed it, for example, the part of the standard I/O library ( libc ) containing printf() . When processing a page fault, the kernel will first check to see if the page is already around and, if it is, will just map that existing page into the address space of the current process. This means pages might be shared among many different processes at the same time (which makes calculations like "how much memory is my program using" rather difficult to do correctly). Finding a page in memory results in a soft page fault : the only action the kernel needs to do is connect it. A hard page fault is one that needs actual disk I/O to complete, since nobody else has the correct page in memory at that time.



PANIC. UNIX System Crash Dump Analysis Handbook
PANIC! UNIX System Crash Dump Analysis Handbook (Bk/CD-ROM)
ISBN: 0131493868
EAN: 2147483647
Year: 1994
Pages: 289
Authors: Chris Drake

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net