We often get errors from a computer system that we just have no idea of. Although we try to search for it in the internet, more often than not the results that we get are far too technical for non-IT people to understand.
One of these errors or conditions is a page fault.
WHAT IS A PAGE?
In computer terminology a page is a fixed-length block of memory that is used as a unit to transfer data between the physical memory and an external memory.
WHAT, THEN, IS A PAGE FAULT?
A page fault is an interrupt or exception that occurs when a program requests data that is not currently in real memory. The interrupt triggers the operating system to fetch the data from a virtual memory and load it into RAM.
Although they are called faults or errors, they are not necessarily fatal.
WHAT CAUSES A PAGE FAULT?
Your computer hardware generates a page fault when:
# The page corresponding to the requested address is not loaded into memory. This is called a Major Page Fault and is more expensive and affects the system’s disk latency.
# The requested page is loaded into memory but the hardware is not updated of the present status. This is categorized as a Minor or Soft Page Fault. This happens if the part of the memory you want to access if shared by several programs and the page is already in use by another program. This type of page fault is less expensive and doesn’t involve disk latency.
# An attempt to read the memory is done with the use of a null pointer. This is an Invalid Page Fault. In this instance, the operating system maps a dummy page for catching null pointers.
WHAT CAN A PAGE FAULT DO TO YOUR SYSTEM?
Generally, page faults affect your computer’s performance and could result in thrashing, wherein your computer to a decreased amount of work even with increased amount of resources. It decreases disk latency to more than double the average latency of 3ms making the system 40000 times slower. In effect, multi-tasking will be too much of a chore and simple file access will take ages before giving you a result.
WHAT CAN BE DONE TO FIX PAGE FAULT?
Two primary focuses for optimization focuses on reducing memory usage and improving memory locality. Thus, it can be wise to say that the more memory you have the lesser you could be at risk of page faults. First, more memory would reduce the need for the system to allocate memory sharing for all your softwares. Secondly, there would be more space for swapping in and out of file during access.
Additionally, you can also do the following solutions:
# Delete any temporary files residing on the hard disk. No matter how big or how small they are, fact still remains that it is using memory space that could be put to better use.
# Check your hard disk for bad sectors or errors by running Scandisk and Disk Defragmentation tool.
# If the page fault constantly happens in only one program, verify that it is compatible to your operating system or if there are any patches or software updates that you have to install.
# Uninstall any recently added software or hardware to verify that it is not causing the page fault.
# If a new memory has just been installed; remove this first to make sure that it is not what is causing the exception. Make sure that all care is taken when adding a new memory to your system.
AN EXPLANATION FOR THE NON-TECHIES
Imagine a library situation where:
# Student is the software
# Librarian is the page fault handler
# Card Catalogue is the page pointer
# Books are the data
# Shelves are the pages
Student goes into the library with an aim to find a specific book. Student uses a card catalogue which contains the location of the book that he wants to access. The following scenarios occur:
# The student searches for the particular shelf and couldn’t find it where it is supposed to be. He tells the librarian that the shelf he is looking for is not there. Being that it is impossible to move the shelf, the librarian tells him to look again, so the student looked at every single shelf. This is a major page fault because the page itself is not found.
# The student looks for the shelf as described in the card catalogue and finds it. He then looks for the book, but since the ratio of a single book with respect to the number of students is not 1:1, he couldn’t find the book because it was already taken by another student. He then raises this issue with the librarian and the librarian checked her system and found that another student has indeed taken the book before him. There had been a delay with what the student has to do, but since it was checked that the book is not there the student would have to go through searching the shelves again. This now is the minor page fault.