0% found this document useful (0 votes)
72 views18 pages

"Page Replacement Algorithms": - A-28 Manasi Dhote A-32 Akshat Gandhi A-63 Dhruv Mistry

The document discusses different page replacement algorithms used in operating systems: 1) Optimal page replacement algorithm replaces pages that will not be used for the longest time in the future, but it requires knowledge of future page requests. 2) First In First Out (FIFO) algorithm replaces the oldest page, tracking pages in a queue. 3) Least Recently Used (LRU) algorithm replaces the page that has been unused for the longest time, tracking recent page usage. Examples are provided to demonstrate how each algorithm works in practice. The goal of page replacement algorithms is to reduce page faults by intelligently selecting pages to remove from memory.

Uploaded by

Manasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views18 pages

"Page Replacement Algorithms": - A-28 Manasi Dhote A-32 Akshat Gandhi A-63 Dhruv Mistry

The document discusses different page replacement algorithms used in operating systems: 1) Optimal page replacement algorithm replaces pages that will not be used for the longest time in the future, but it requires knowledge of future page requests. 2) First In First Out (FIFO) algorithm replaces the oldest page, tracking pages in a queue. 3) Least Recently Used (LRU) algorithm replaces the page that has been unused for the longest time, tracking recent page usage. Examples are provided to demonstrate how each algorithm works in practice. The goal of page replacement algorithms is to reduce page faults by intelligently selecting pages to remove from memory.

Uploaded by

Manasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

“Page Replacement

Algorithms”
-
A-28 Manasi Dhote
A-32 Akshat Gandhi
A-63 Dhruv Mistry
Table of contents
01 02 03
Introduction Optimal Page First In First Out
Replacement ALgorithm

04 05 06
Least Recently Used Examples Conclusion
01
About the
project
Introduction
In an operating system that uses paging for memory management, a page
replacement algorithm is needed to decide which page needs to be replaced
when a new page comes in.

Page Fault – A page fault happens when a running program accesses a memory
page that is mapped into the virtual address space but not loaded in physical
memory.

Since actual physical memory is much smaller than virtual memory, page faults
happen. In case of a page fault, Operating System might have to replace one of
the existing pages with the newly needed page. Different page replacement
algorithms suggest different ways to decide which page to replace. The target
for all algorithms is to reduce the number of page faults.
02
Optimal Page
Replacement ALgorithm
Optimal Page replacement –

In this algorithm, pages are


replaced which would not be used
for the longest duration of time in
the future.

Example: Consider the page


references 7, 0, 1, 2, 0, 3, 0, 4, 2, 3,
0, 3, 2, with 4 page frame. Find
number of page faults.
Optimal Page replacement –
Initially, all slots are empty, so when 7 0 1 2 are allocated to
the empty slots —> 4 Page faults
0 is already there so —> 0 Page fault.
when 3 came it will take the place of 7 because it is not used
for the longest duration of time in the future.—>1 Page fault.
0 is already there so —> 0 Page fault..
4 will takes place of 1 —> 1 Page Fault.

Now for the further page reference string —> 0 Page fault
because they are already available in the memory.
Optimal page replacement is perfect, but not possible in
practice as the operating system cannot know future
requests. The use of Optimal Page replacement is to set up a
benchmark so that other replacement algorithms can be
analyzed against it.
03
First In First Out
(FIFO)
First In First Out

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 replaced page in the front of the queue is selected for
removal.

Example-1Consider page reference string 1, 3, 0, 3, 5, 6, 3 with 3


page frames.Find the number of page faults.
First In First Out

Initially, all slots are empty, so when 1, 3, 0 came they are allocated
to the empty slots —> 3 Page Faults.
when 3 comes, it is already in memory so —> 0 Page Faults.
Then 5 comes, it is not available in memory so it replaces the
oldest page slot i.e 1. —>1 Page Fault.
6 comes, it is also not available in memory so it replaces the oldest
page slot i.e 3 —>1 Page Fault.
Finally, when 3 come it is not available so it replaces 0 1 page fault
.
04
LEAST RECENTLY USED
(LRU)
LEAST RECENTLY USED (LRU)

In this algorithm, page will be replaced which is least


recently used.

Example-3 Consider the page reference string 7, 0, 1, 2,


0, 3, 0, 4, 2, 3, 0, 3, 2 with 4 page frames.Find number of
page faults.
LEAST RECENTLY USED (LRU)

Initially, all slots are empty, so when 7 0 1 2 are allocated


to the empty slots —> 4 Page faults
0 is already their so —> 0 Page fault.
when 3 came it will take the place of 7 because it is least
recently used —>1 Page fault
0 is already in memory so —> 0 Page fault.
4 will takes place of 1 —> 1 Page Fault
Now for the further page reference string —> 0 Page fault
because they are already available in the memory.
Conclusion
Thus, we successfully have learnt about the various types of Page
Replacement Algorithms.
We have also, studied the examples for the same.
Thank
You!

You might also like