Page fault
From Wikipedia, the free encyclopedia
In computer storage technology, a page fault is an interrupt (or exception) to the software raised by the hardware, when a program accesses a page that is not mapped in physical memory. The software that handles the page fault is generally part of an operating system and the hardware that detects this situation is the memory management unit in processors. Then an operating system can try to handle the page fault by making the required page accessible at a location in physical memory or kill the program in case it is an illegal access.
Situations when a page fault can happen:
- when a program accesses a memory location in its memory and the page corresponding to that memory is not loaded;
- when a program accesses a memory location in its memory and the program does not have privileges to access the page corresponding to that memory.
Contrary to what its name might suggest, a page fault is not necessarily a fatal error. In any operating system that utilises virtual memory to increase the amount of memory available to programs, page faults are a common and necessary occurrence. The general protection fault, or the less common "invalid page fault," found on computers running a Microsoft Windows operating system, are actually generated by the exception handling code in the operating system's page fault handler. When a page fault occurs that would cause Windows to page in memory that the currently-running program does not have permissions to access, such as accessing memory that properly belongs to another process, the system will generate a "general protection fault." If a page fault occurs that references a non-existent memory page, such as trying to read a null pointer, the system may alternately generate an "invalid page fault." (Recent versions of Windows replace both these and other hardware-generated fault errors with a single, less technical error simply stating that "this program must close", but the underlying causes are the same). UNIX and UNIX-like operating systems will handle these conditions by delivering signals, such as SIGSEGV ("segmentation violation"), to the offending process. In all of these cases, the fatal error is ultimately the fault of poorly behaving software, and not of the hardware.
Page faults, by their very nature, degrade the performance of a program or operating system and in the degenerate case can cause thrashing. Optimizations to programs and the operating system that reduce the number of page faults that occur improves the program's or the entire system's performance. The two primary focuses of the optimization effort focus on reducing overall memory usage and improving memory locality. Generally, making more physical memory available also reduces page faults.
Many page replacement algorithms have been proposed, implementing a heuristic to reduce the incidence of page faults.
[edit] See also
[edit] References
- John L. Hennessy, David A. Patterson, Computer Architecture, A Quantitative Approach (ISBN 1-55860-724-2)
- Tanenbaum, Andrew S. Operating Systems: Design and Implementation (Second Edition). New Jersey: Prentice-Hall 1997.
[edit] External links
- "So What Is A Page Fault?" from OSR Online (a Windows-specific explanation)
- "Virtual Memory Details" from some Red Hat page.