What happens on page fault?

What happens on page fault?

A page fault occurs when a program attempts to access a block of memory that is not stored in the physical memory, or RAM. The fault notifies the operating system that it must locate the data in virtual memory, then transfer it from the storage device, such as an HDD or SSD, to the system RAM.

What do you mean by page fault in OS?

A page fault (sometimes called #PF, PF or hard fault) is a type of exception raised by computer hardware when a running program accesses a memory page that is not currently mapped by the memory management unit (MMU) into the virtual address space of a process.

When does a page fault occur in a computer?

A page fault occurs when a program attempts to access a block of memory that is not stored in the physical memory, or RAM.

When does an invalid page fault cause a program to crash?

However, an invalid page fault may cause a program to hang or crash. This type of page fault may occur when a program tries to access a memory address that does not exist. Some programs can handle these types of errors by finding a new memory address or relocating the data.

What’s the difference between minor and major page fault?

When the CPU needs to access a page that isn’t in memory it raises a page fault. A major page fault is one that can only be satisfied by accessing the disk. A minor page fault can be satisfied by sharing pages that are already in memory. Swapping occurs when pages are written to the disk to free memory so that a major page fault can be satisfied.

When do page faults and memory swap in / outs occur?

If a system is heavily loaded then an undesirable situation can occur when the latest page fault requires a page to be swapped-in but there still isn’t enough free memory. So to satisfy the swap-in the kernel must first swap-out. At this stage there is a danger that the system performance will degrade.