Difference Between Similar Terms and Objects

Difference Between Page Fault and Hard Fault

Each page has been assigned a frame in the main memory and when a thread attempts to make a reference to a page whose frame is not found in the main memory, a page fault occurs. If the page is truly not present in the physical memory and it has to be retrieved from secondary storage, such as a hard disk, the fault occurs which is classified as a hard page fault.

What is Page Fault?

A page fault is a type of exception initiated by the hardware of a computer to notify the operating system of references to frameless pages. Simply put, a page fault occurs when a program tries to access the data residing in a page that is not stored in the main memory or physical memory. Let’s say a particular program has five pages out of which two pages are loaded into the main memory into two separate frames. So, when a new page is called by the CPU, one of few things may occur. If that page is not found in the main memory, it’s called a page fault. So, when the CPU demands a particular page to be executed, but the page is not available in the main memory, page fault occurs. The page actually resides in the secondary memory or virtual memory. This whole mechanism is handled by the memory management unit (MMU) hardware.

What is Hard Page Fault?

If the desired page is not present in the main memory and it has to be fetched or paged in from the virtual memory, the fault is classified as a ‘hard’ page fault. Each page table entry has a validity bit, which indicates if the page has been assigned a frame in the main memory. So when a program makes a reference to a page whose validity bit is zero, page fault occurs. The OS then intervenes and assigns a suitable frame to the page. The page table entry actually tells us the page is on disk. So, when a desired page is not found in the main memory and it is swapped out to the page file on the disk instead, hard page fault occurs. The OS has to retrieve the page from the disk subsystem which causes the program to wait significantly, which in turn reduces performance. If the page resides in the cache memory, a soft page fault occurs.

Difference between Page Fault and Hard Fault

Exception 

– A page fault is a type of exception that occurs when a program tries to access a page that is in its address space, but is not found in the main memory or physical memory. So, when the CPU demands a particular page to be executed, but the page is not available in the main memory, page fault occurs. If the desired page is not present in the main memory and it has to be fetched or paged in from the virtual memory, the fault is classified as a ‘hard’ page fault. Simply put, if the page has to be retrieved from the disk, a hard page fault occurs.

Handling

 – The memory management unit (MMU) signals a page fault to the CPU which then raises a page fault exception, which in turn prompts the operating system to locate the page in the main memory. The OS then assigns a suitable frame to the page. This action is managed by a module called ‘pagefault handler.’ The page table is then updated and the page entry should point to the right frame by now. The program is then ready to run again, but this time without a page fault. When a hard page fault occurs, the OS finds a free location for the page and once the space is available, the OS reads the page data into main memory, and updates the entry in the MMU.

Page Fault vs. Hard Page Fault: Comparison Chart

Summary

Page fault is one of the common memory management problems when dealing with virtual memory or secondary memory. A page fault, on the contrary to what its name suggests, is not actually a fault; it is an exception that occurs when a program attempts to access an address on a page which is not available in the main memory where it is supposed to be located. The MMU then signals the CPU of the page fault and the CPU then prompts the OS to locate the page in memory while the thread goes into waiting. So, the OS then locates the desired page in another part of the physical memory or in worst case, finds it on the disk, in which case, the fault is called a hard page fault. The OS then assigns a suitable frame to the page and updates the page table. This whole mechanism is handled by a module called the pagefault handler.

Latest posts by Sagar Khillar (see all)

Sharing is caring!


Search DifferenceBetween.net :




Email This Post Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.


Leave a Response

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

References :


[0]Singh, Amit. Mac OS X Internals: A Systems Approach. Massachusetts, United States: Addison-Wesley, 2006. Print

[1]Hennessy, John L. and David A. Patterson. Computer Architecture: A Quantitative Approach. Amsterdam, Netherlands: Elsevier, 2002. Print

[2]Kifer, Michael and Scott A. Smolka. Introduction to Operating System Design and Implementation: The OSP 2 Approach. Berlin, Germany: Springer, 2007. Print

[3]Morimoto, Rand et al. Microsoft Windows Server 2003 Unleashed. Indiana, United States: Sams Publishing, 2006. Print

[4]Image credit: https://live.staticflickr.com/66/178319242_88bf96f705_b.jpg

[5]Image credit: https://commons.wikimedia.org/wiki/File:Linux_kernel_panic_on_an_information_screen.jpg

Articles on DifferenceBetween.net are general information, and are not intended to substitute for professional advice. The information is "AS IS", "WITH ALL FAULTS". User assumes all risk of use, damage, or injury. You agree that we have no liability for any damages.


See more about : ,
Protected by Copyscape Plagiarism Finder