You are on page 1of 14

[PAGE FAULT]

ABSTRACT
In the memory management system, the page replacement algorithm is an inevitable concept.
When the Kernel creates a process, the pages are required to be in the main memory. If the
pages are not found in the main memory [4], then it is called page fault.

A page fault is an essential concept in computer memory management and virtual memory
systems. It occurs when a program or process attempts to access a specific page of memory
that is currently not in physical RAM (Random Access Memory). When this happens, the
operating system intervenes to handle the page fault and bring the required page into physical
memory, making it accessible to the program.

[GOVERNMENT POLYTECHNIC Page


[PAGE FAULT]

INTRODUCTION

In modern computing, paging and memory swapping are two common memory management
techniques for the allocation and de allocation of memory. Memory management can be used
to reduce fragmentation of a program's address space, improve performance by reducing cache
misses, or increase security by preventing buffer overflows.

Memory management in operating systems involves a combination of methods for memory


allocation and usage tracking by applications and processes.

The memory management unit (MMU) maps logical addresses to physical addresses while
managing the movement of processes between the storage disk and main memory during
execution.

In this article, we’ll examine pertinent issues with page faults and memory swaps as
commonly occurring exceptions. We’ll also look at the typical scenarios that cause them.

[GOVERNMENT POLYTECHNIC Page


[PAGE FAULT]

Page Fault:
A page fault (sometimes called #PF, PF or hard fault)[a] 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.
Logically, the page may be accessible to the process, but requires a mapping to be added to
the process page tables, and may additionally require the actual page contents to be loaded
from a backing store such as a disk. The processor's MMU detects the page fault, while the
exception handling software that handles page faults is generally a part of the operating
system kernel.
When handling a page fault, the operating system tries to make the required page accessible at
the location in physical memory or terminates the program in cases of an illegal memory
access.

Different Types Of Page Fault

 Minor or soft page fault:-

If the page is loaded in memory at the time the fault is generated, but is not marked in the
memory management unit as being loaded in memory, then it is called a minor or soft page
fault.

 Major or hard page fault:-

 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

[GOVERNMENT POLYTECHNIC Page


[PAGE FAULT]

the page

[GOVERNMENT POLYTECHNIC Page


[PAGE FAULT]

is not loaded in memory at the time of the fault, then it is called a major or hard page
fault.

 Invalid page fault:-

 If a page fault occurs for a reference to an address that is not part of the virtual
address space, meaning there cannot be a page in memory corresponding to it, then it
is called an invalid page.

Demand paging:-

 In computer operating systems, demand paging (as opposed to anticipatory paging) is


a method of virtual memory management. In a system that uses demand paging,

 the operating system copies a disk page into physical memory only if an attempt is
made to access it and that page is not already in memory (i.e., if a page fault occurs). It
follows that a process begins execution with none of its pages in physical memory, and
many page faults will occur until most of a process's working set of pages are located
in physical memory.

[GOVERNMENT POLYTECHNIC Page


[PAGE FAULT]

Advantages

 Only loads pages that are demanded by the executing process.


 there As is more space in main memory, more processes can be loaded, reducing
the context switching time, which utilizes large amounts of resources.
 Less loading latency occurs at program start-up, as less information is accessed
from secondary storage and less information is brought into main memory.
 As main memory is expensive compared to secondary memory, this technique
helps significantly reduce the bill of material (BOM) cost in smart phones for
example. Symbian OS had this feature.

[GOVERNMENT POLYTECHNIC Page


[PAGE FAULT]

 Disadvantages

 Low-cost, low-power embedded systems may not have a memory management unit
that supports page replacement.

 Memory management with page replacement algorithms becomes slightly


more complex.

 Possible security risks, including vulnerability to timing attacks; see Percival, Colin
(2005-05-13). "Cache missing for fun and profit" (PDF). BSD Can 2005.
(Specifically the virtual memory attack in section 2).

 Thrashing which may occur due to repeated page fault.

 Individual programs face extra latency when they access a page for the first time.

[GOVERNMENT POLYTECHNIC Page


[PAGE

.Page replace mentment algorithm

 In an operating system that uses paging for memory management, a page


replacement algorithm is needed to decide which needs to be replaced when new
page comes in.

[GOVERNMENT POLYTECHNIC
Page 7
[PAGE

FIFO Algorithm
This is the simplest page replacement algorithm. In this algorithm, the operating system
keeps track of all pages in the memory in a queue, the oldest page is in the front of the
queue. When a page needs to be repage in the front of the queue is selected for
removal. Example-1:- Consider page reference string 1, 3, 0, 3, 5, 6 with 3 page
frames. Find number of page faults. : - This is the simplest page replacement
algorithm. In this algorithm, the operating system keeps track of all pages in the
memory in a queue, the oldest page is in the front of the queue. When a page needs to
be repage in the front of the queue is selected for removal. Consider page reference
string 1, 3, 0, 3, 5, 6 with 3 page number of page faults. This is the simplest page
replacement algorithm. In this algorithm, the operating system keeps track of all pages
in the memory in a queue, the oldest page is in the front of the queue. When a page

[GOVERNMENT POLYTECHNIC Page 8


[PAGE

needs to be replaced.

[GOVERNMENT POLYTECHNIC Page 9


[PAGE

 List Recently Used

 In this algorithm page will be replaced which is least recently used.

 Example:- consider the page reference using 7, 0, 1, 2, 0, 3, 4, 0, 2, 3, 0, 3, 2 with


4 prame. Find the number of page fault.

[GOVERNMENT POLYTECHNIC Page


[PAGE

Conclusion

Page Fault in OS, Page errors are more often than other errors. If software tries to
access memory not present in physical memory, a page fault will occur (main
memory).
[GOVERNMENT POLYTECHNIC Page
[PAGE

The fault instructs the operating system to move all data from secondary memory to its
primary memory, which might be a hard drive, by tracing it into virtual memory
management.

References
[GOVERNMENT POLYTECHNIC Page
[PAGE

https://www.studocu.com

https://datatrained.com

[GOVERNMENT POLYTECHNIC Page

You might also like