What are page faults in the context of memory management in Linux? Differentiate between minor and major page faults and explain their impact on system performance.
If a memory page isn't ready when a process wants to use it, the process triggers a page fault. In the event of a page fault, the kernel takes control of the CPU from the process in order to get the page ready.
There are two types of page faults:-
Minor Page Fault: A minor page fault occurs when the desired page is actually in main memory, but the MMU doesn't know where it is. This happens when the process requests more memory or when the MMU doesn't have enough space to store all of the page locations for a process.
Major Page Fault: A major page fault occurs when the desired memory page isn't in main memory at all, which means the kernel must load it from the disk or some other slow storage mechanism. Some major faults are unavoidable as they occur when we are loading the code from a disk when running a program for the first time.
Minor faults are not much of an issue and many occur as a process runs. Major faults if larger in number can bog the system down resulting in less or no memory for the remaining process waiting in the queue.
Page fault trap occurs if the requested page is not into memory. The page fault primarily causes an exception, which is used to notify the operating system to retrieve the "pages" from virtual memory to continue operation. Once all of the data has been placed into physical memory, the program resumes normal operation. The Page fault process occurs in the background, and thus the user is unaware of it.
Page Fault Terminology 1)Page Hit 2) Page Miss 3) Page Fault Time 4) Page Fault Delay 5) Minor Page Fault Etc
Minor Page Fault-If a process needs data and that data exists in memory but is being allotted to another process at the same moment, it is referred to as a minor page fault.
If a memory page isn't ready when a process wants to use it , the process triggers a page fault.
Minor page fault: a minor page fault occurs when the desired page is actually in main memory, but the MMU doesn't know where it is. this can happen when the process requests more memory or when the MMU doesn't have enough space to store all of the page locations for a process(the MMU's internal mapping table is usually quite small).
In this case, the kernel tells the MMU about the page and permits the process to continue. Minor page faults are nothing to worry about and many occur as a process runs.
Major Page Fault:
A major page fault occurs when the desired memory page isn't in main memory at all, which means that the kernel must load it from the disk or some other slow storage mechanism. A lot of major page faults will bog the system down, because the kernel must do a substantial amount of work to provide the pages , robbing the normal processes of their chance to run.