In computer storage technology, a page is a fixed-length block of memory that is used as a unit of transfer between physical memory and external storage like a disk, and a page fault is an interrupt (or exception) to the software raised by the hardware, when a program accesses a page that is mapped in address space, but not loaded in physical memory. Computer data storage, often called storage or memory, refers to Computer components devices and recording media that retain digital In a context of Computer Virtual memory, a page, memory page, or virtual page is a fixed-length block of Main memory, that is contiguous Computer data storage, often called storage or memory, refers to Computer components devices and recording media that retain digital A hard disk drive ( HDD) commonly referred to as a hard drive, hard disk, or fixed disk drive, is a Non-volatile storage device In Computing, an interrupt is an asynchronous signal from hardware indicating the need for attention or a synchronous event in software indicating the need for a change Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of a condition that changes the normal flow of execution
The hardware that detects this situation is the memory management unit in a processor. A memory management unit ( MMU) sometimes called paged memory management unit ( PMMU) is a Computer hardware component responsible for handling The exception handling software that handles the page fault is generally part of an operating system. Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of a condition that changes the normal flow of execution An operating system (commonly abbreviated OS and O/S) is the software component of a Computer system that is responsible for the management and coordination The operating system tries to handle the page fault by making the required page accessible at a location in physical memory or kills the program in case it is an illegal access.
Contents |
Contrary to what their name might suggest, page faults are not necessarily fatal and are common and necessary to increase the amount of memory available to programs in any operating system that utilizes virtual memory, including Microsoft Windows, Mac OS X, Linux and Unix. Virtual memory is a Computer system technique which gives an application program the impression that it has contiguous working memory while in fact it may be physically Microsoft Windows is a series of Software Operating systems and Graphical user interfaces produced by Microsoft. Mac OS X (mæk oʊ ɛs tɛn is a line of computer Operating systems developed marketed and sold by Apple Inc, the latest of which is pre-loaded on all currently Linux (commonly pronounced ˈlɪnəks Unix (officially trademarked as UNIX, sometimes also written as Unix with Small caps) is a computer
Hardware generates a page fault for page accesses where:
The closely related exception known as the protection fault is generated for page accesses where:
Protection fault can also be generated for many other invalid accesses not related to paging.
On the x86 architecture, accesses to pages that are not present and accesses to pages that do not conform to the permission attributes for a given page (protection faults as described above) are both reported via the page fault processor exception. See also X86 assembly language The generic term x86 refers to the most commercially successful Instruction set architecture in the history of Personal Internally, the processor hardware provides information to the page fault handler that indicates what sort of access triggered the fault, so that these scenarios may be differentiated from the perspective of the operating system. An operating system (commonly abbreviated OS and O/S) is the software component of a Computer system that is responsible for the management and coordination The usage of the term protection fault (when speaking in relation to page faults) is thus not to be confused with the general protection fault exception, which is used to signal segmentation-based memory access violations, as well as a variety of other general protection related violations (such as the use of an instruction that is not valid at the current privilege level). A General Protection Fault ( GPF) in the Intel X86 and AMD X86-64 architectures and other unrelated architectures is a In computing memory segmentation is one of the most common ways to achieve Memory protection; another common one is Paging. The concept of privilege level refers to protecting resources on a CPU.
| Page Mapped | Page Loaded | Page Status | Page access valid | Exception |
|---|---|---|---|---|
| yes | yes | present | yes | No exception |
| yes | -- | not present | yes | Page fault |
| no | yes | yes | yes | Protection fault |
| -- | -- | -- | no | Protection fault |
If the page is loaded in memory at the time the fault is generated, but its status is not updated as 'present' in hardware, then it is called a minor or soft page fault. This could happen if the memory is shared by different programs and the page is already brought into memory for other programs. In Computing, shared memory is a memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies Since these faults do not involve disk latency, they are faster and less expensive than major page faults.
If the page is not loaded in memory at the time the fault is generated, then it is called a major or hard page fault. Major faults are more expensive than minor page faults and add disk latency to the interrupted program's execution. This is the mechanism used by an operating system to increase the amount of program memory available on demand. The operating system delays loading parts of the program from disk until the program attempts to use it and the page fault is generated.
If a page fault occurs that attempts to read the memory referenced by a null pointer, the system may alternatively generate an invalid page fault. The operating system maps a dummy page for catching null pointers.
When a program attempts invalid page accesses, for example trying to access pages not mapped into its memory, tries to write to read-only pages, or tries to modify privileged pages, the system hardware will generate a protection fault. Not all protection faults are illegal accesses, and they are the mechanism used by an operating system to implement copy on write access to share the same copy of memory among many programs until one of the programs wants to modify its copy. Copy-on-write (sometimes referred to as "COW" is an optimization strategy used in Computer programming.
A program trying to access memory that belongs to another process is attempting 'illegal access' which generates a protection fault. The operating system handles this protection fault much like an invalid page fault: The operating system temporarily blocks 'write permission' until a page fault is generated, then creates new access information to allow the program to successfully find this memory.
Note that in terms of the x86 architecture, memory protection violations reported via the page fault mechanism (protection faults, as described in this article) are distinct from memory protection violations reported via the general protection fault mechanism. See also X86 assembly language The generic term x86 refers to the most commercially successful Instruction set architecture in the history of Personal A General Protection Fault ( GPF) in the Intel X86 and AMD X86-64 architectures and other unrelated architectures is a The general protection fault mechanism is used to report segmentation-based memory access violations as well as other classes of protection violations. In computing memory segmentation is one of the most common ways to achieve Memory protection; another common one is Paging. The page fault mechanism is used to report paging-based memory protection violations.
Illegal accesses and invalid page faults can result in a program crash, segmentation error, bus error or core dump depending on the semantics of the operating system environment. A core dump is the recorded state of the working memory of a Computer program at a specific time generally when the program has terminated abnormally ( crashed Frequently these problems are the manifestation of software bugs, but the hardware memory errors frequently caused by overclocking may corrupt pointers causing even correct software to fail.
Operating systems such as Windows and UNIX (and other UNIX-like systems) provide differing mechanisms for reporting errors caused by page faults. Microsoft Windows is a series of Software Operating systems and Graphical user interfaces produced by Microsoft. Unix (officially trademarked as UNIX, sometimes also written as Unix with Small caps) is a computer A Unix-like (sometimes shortened to *nix) Operating system is one that behaves in a manner similar to a Unix system while not necessarily conforming Windows uses structured exception handling to report page fault-based invalid accesses as access violation exceptions, and UNIX (and UNIX-like) systems typically use signals, such as SIGSEGV, to report these error conditions to programs. A segmentation fault (often shortened to segfault) is a particular error condition that can occur during the operation of Computer software. On POSIX -compliant platforms SIGSEGV is the signal thrown by Computer programs making invalid memory references or Segmentation faults The
If the program that received the error does not handle it, then the operating system typically performs some sort of default action, typically involving the termination of the running process that caused the error condition, and a notification to the user that the program has malfunctioned. In this vein, recent versions of Windows often report such problems with less technical error messages simply stating something along the lines of "this program must close" (an experienced user or programmer with access to a debugger can still retrieve detailed information, if necessary). A programmer is someone who writes Computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist A debugger is a Computer program that is used to test and Debug other programs Additionally, recent Windows versions also write a minidump (similar in principle to a core dump) describing the state of the crashed process for later analysis alongside such less-technical error messages. A core dump is the recorded state of the working memory of a Computer program at a specific time generally when the program has terminated abnormally ( crashed UNIX and UNIX-like operating systems typically report these conditions to the user with error messages such as "segmentation violation", or "bus error". Unix (officially trademarked as UNIX, sometimes also written as Unix with Small caps) is a computer A Unix-like (sometimes shortened to *nix) Operating system is one that behaves in a manner similar to a Unix system while not necessarily conforming
Page faults, by their very nature, degrade the performance of a program or operating system and in the degenerate case can cause thrashing. Computer programs (also software programs, or just programs) are instructions for a Computer. In Computer science, thrash (verb is the term used to describe a degenerate situation on a computer where increasing resources are used to do a decreasing amount of work Optimizations to programs and the operating system that reduce the number of page faults that occur improve the performance of the program or even the entire system. In Computing, optimization is the process of modifying a system to make some aspect of it work more efficiently or use fewer resources The two primary focuses of the optimization effort focus on reducing overall memory usage and improving memory locality. In Computer science, locality of reference, also known as the principle of locality, is the phenomenon of the same value or related storage locations 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. In a Computer Operating system that utilizes Paging for Virtual memory Memory management, page replacement algorithms decide which In Computer science, a heuristic algorithm or simply a Heuristic is an Algorithm that ignores whether the solution to the problem can be proven
How much does a page fault reduces the performance of your computer? An average hard disk has an average latency of 3ms and seek of 5ms and a transfertime of 0,05ms/page. So the total time for paging comes near 8ms (8. 000. 000ns). If the memory access is 200ns. Then the page fault would make the system 40000 times slower.