0% found this document useful (0 votes)
30 views11 pages

OSY Prachi CH Project

This document is a project report submitted by Prachi Labade to the Maharashtra State Board of Technical Education on page replacement algorithms. It explores various page replacement algorithms like FIFO, LRU, optimal, clock, LFU, and MFU, discussing their descriptions, advantages, disadvantages, and examples. The conclusion emphasizes that page replacement algorithms play an important role in managing memory efficiently in operating systems by determining which pages to evict from physical memory.

Uploaded by

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

OSY Prachi CH Project

This document is a project report submitted by Prachi Labade to the Maharashtra State Board of Technical Education on page replacement algorithms. It explores various page replacement algorithms like FIFO, LRU, optimal, clock, LFU, and MFU, discussing their descriptions, advantages, disadvantages, and examples. The conclusion emphasizes that page replacement algorithms play an important role in managing memory efficiently in operating systems by determining which pages to evict from physical memory.

Uploaded by

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

K.E.

SOCIETY’S

RAJARAMBAPU INSTITUTE OF TECHNOLOGY’S (POLYTECNIC)

LOHEGAON, PUNE-47

A PROJECT REPORT

ON

“Page Replacement Algorithm”


SUBMITED TO
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
INPARTIAL FULFILLMENT OF THE REQUIRMENTS FOR THE AWARD OF
DIPLOMA IN COMPUTER ENGNEERING
BY

Prachi Labade
Prof . N. Tavares

DEPARTMENT OF COMPUTER ENGINEERING


RAJARAMBAPU INSTITUTE OF TECHNAOLOGY’S (POLYTECHNIC)
LOHEGAON, PUNE-411047(2023-2024)

Acknowledgement
We have an opportunity to express our deep sense of graduate to Prof. N. Tavares (project
guide), Department of Computer for her valuable guidance and suggestion during the course of
this project work. Her encouragement at all stages has contribution greatly to complete this
project to work systematic manner. We thankful to Prof. V.B. Jadhav, Head of Computer
Department for his continuous support to complete this project work. We thankful to Dr.
K.H.Munde, principal of Rajarambapu Institute of Technology (Polytechnic) Lohegaon, pune-
411047, for allowing us to carry out his project.

INDEX
SR.NO. TOPIC NAME
1. Introduction
2. Page Replacement Algorithms
3. Examples
4. Conclusion

RAJARAMBAPU INSTITUTE OF TECHNOLOGY’S(POLETECHNIC)


LOHEGAON PUNE -411047

CERTIFICATE
This is to certify that, the project entitled “Page Replacement Algorithm” has been successfully
completed by “Prachi Labade”, impartial fulfillment of the requirement of Engineering
Diploma Program in Computer of Maharashtra State Board of Technical Education During
Academic Year 2023-24.

Project Guide Head of department Principal


Prof. N. Tavares Prof. V.B. Jadhav Dr.K.H.Munde

INTRODUCTION
In modern operating systems, managing memory efficiently is crucial for system performance.
Page replacement algorithms play a vital role in this by determining which page in memory to
replace when new pages need to be loaded. This report explores various page replacement
algorithms, their pros and cons, and their real-world applications. Additionally, it discusses the
challenges associated with implementing these algorithms and their implications on system
performance.
Memory management is a fundamental aspect of operating systems. To optimize memory
utilization and performance, operating systems employ page replacement algorithms. These
algorithms determine which page to replace when the available memory is insufficient to
accommodate new pages or processes.

Page Replacement Algorithms :


1. FIFO (First-In, First-Out)

Description: The FIFO page replacement algorithm is one of the simplest algorithms to
implement. It replaces the oldest page in memory, i.e., the page that was brought into memory
first. It maintains a queue or buffer to keep track of the order in which pages were loaded, and
when a page needs to be replaced, it selects the one at the front of the queue.

Advantages:
 Simplicity: FIFO is easy to implement and requires minimal computational overhead.
 Predictable behavior: Since it replaces the oldest page, its behavior is predictable and not
affected by page access patterns.

Disadvantages:

 Belady's Anomaly: FIFO can suffer from Belady's Anomaly, where increasing the
number of page frames does not necessarily improve performance.
 Poor in practice: It often does not perform well in real-world scenarios where page access
patterns are not purely sequential.

2. LRU (Least Recently Used)

Description: The LRU page replacement algorithm replaces the page that has not been used for
the longest time. It requires maintaining a list of pages in memory and updating this list every
time a page is accessed. When a page needs to be replaced, the algorithm selects the page that
was least recently accessed.

Advantages:

 Optimality: LRU, in theory, provides an optimal page replacement strategy by selecting


the page that is least likely to be used in the near future.
 Good performance: In many scenarios, LRU performs well, especially when page access
patterns exhibit temporal locality.

Disadvantages:

 High computational overhead: Implementing LRU can be computationally expensive, as


it requires constantly updating the list of page accesses.
 Practical challenges: LRU's optimality is theoretical, and in practice, maintaining the
necessary data structures can be complex.

3. Optimal

Description: The optimal page replacement algorithm, also known as MIN (Minimum), replaces
the page that will not be used for the longest time in the future. It serves as an ideal benchmark to
compare other algorithms but is not practical for actual implementation, as it would require
foreknowledge of future page access patterns, which is not feasible.

Advantages:
 Benchmark: Optimal provides a benchmark against which the performance of other
algorithms can be compared.

Disadvantages:

 Impractical: The optimal algorithm cannot be implemented in real-world systems due to


its requirement of knowing future page access patterns.

4. Clock (Second Chance)

Description: The Clock page replacement algorithm is a modification of the FIFO algorithm. It
gives pages a "second chance" before replacement. Pages are arranged in a circular buffer, and
when a page needs to be replaced, the algorithm checks if the page has been referenced since it
was last checked. If it has been referenced, it is given a "second chance" and is not replaced;
otherwise, it is replaced.

Advantages:

 Simplicity: Clock is relatively simple to implement.


 Mitigates FIFO's drawbacks: By providing a second chance to pages that are still in use,
it mitigates the issues of pure FIFO.

Disadvantages:

 May not be optimal: It may still suffer from suboptimal page replacements in some
situations, especially when page access patterns are complex.

5. LFU (Least Frequently Used)

Description: The LFU page replacement algorithm replaces the page that has been used the least
frequently. It maintains a count of how often each page is accessed, and when a page needs to be
replaced, it selects the page with the lowest access count.

Advantages:
 Prioritizes rarely used pages: LFU prioritizes keeping pages that are used less frequently
in memory, which can be useful in certain scenarios.

Disadvantages:

 Sensitivity to initial access patterns: It may perform poorly when initially accessed pages
subsequently become infrequently used.

6. MFU (Most Frequently Used)

Description: The MFU page replacement algorithm replaces the page that has been used the most
frequently. Similar to LFU, it maintains a count of how often each page is accessed. However,
when a page needs to be replaced, it selects the page with the highest access count.

Advantages:

 Prioritizes frequently used pages: MFU aims to keep the pages that are frequently used in
memory, assuming they are more likely to be needed in the future.

Disadvantages:

 Thrashing: MFU can suffer from the "thrashing" problem, where frequently used pages
are replaced too frequently, causing excessive page faults.

Examples :

1. First In First Out (FIFO):

Example 1:

Consider page reference string 1, 3, 0, 3, 5, 6, 3 with 3 page frames. Find the


number of page faults.
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.

Belady’s anomaly proves that it is possible to have more page faults when increasing the number
of page frames while using the First in First Out (FIFO) page replacement algorithm. For
example, if we consider reference strings 3, 2, 1, 0, 3, 2, 4, 3, 2, 1, 0, 4, and 3 slots, we get 9 total
page faults, but if we increase slots to 4, we get 10-page faults.

2.Least Recently Used:


Example-2:

Consider the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4 page frames. Find


number of page faults.
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
In conclusion, page replacement algorithms in operating systems play a vital role in managing
memory efficiently. These algorithms are designed to determine which pages should be evicted
from physical memory when it becomes full, making room for new pages as needed. The choice
of a page replacement algorithm can significantly impact system performance and resource
utilization. Various algorithms, such as FIFO, LRU, and optimal, offer different trade-offs in
terms of simplicity and effectiveness. Selecting the most appropriate algorithm depends on the
specific workload and system requirements. Ultimately, the goal is to minimize page faults and
optimize overall system performance while effectively managing available memory resources.

You might also like