OSY Micro Project

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 14

‘A’

Project Report
On
“PAGE REPLACEMENT ALGORITHMS”

Submitted & Present in the fulfillment of the requirement for the award of
Diploma In Information Technology
By

Harshad Dnyaneshwar Sawant


Vishwajeet Vishnu Borade

Under the Guidance of


Ms.Sugandhi.P.S.

DEPARTMENT OF INFORMATION TECHNOLOGY


NEW SATARA COLLEGE OF ENGINEERING & MANAGEMENT POLY(2023-2024)

1
NEW SATARA COLLEGE OF ENGINEERING AND
MANAGEMENT KORTI-PANDHARPUR

Certificate

This is to certify that the project report “page replacement algorithms” has been
presented successfully and submitted by.
Name of the Student Exam Seat No.
Harshad Dnyaneshwar Sawant
Vishwajeet Vishnu Borade

Student of IT (Information Technology) class in the filfullment For the award of


Diploma in Information Technology as per curriculum laid by Maharashtra State
Board Of Technical Education, Mumbai during the academic year 2023-2024.

Project Guide H.O.D Principal


(Ms. Sugandhi P.S.) (Prof. Puri S.B.) (Prof. Londhe.V.H.)
2
Declaration

We hereby declare that, Dissertation entitled “Page Algorithms replacement” is


completed and submitted by me for the award of diploma engineering in Information
Technology branch, NSCOEM, College, Korti, Pandharpur.
Has not been previously present and to the best of my knowledge for the award of
diploma engineering title of this or any other university or examination body.

PLACE- KORTI, PANDHARPUR


DATE-

3
Acknowledgement
We would like to thank all lecturers of Faculty of Computer Systems &
Software Engineering, University Malaysia Pahang and developer staff in
Bahagian Teknologi Maklumat, Setiausaha Kerajaan Negeri Pahang (SUK)
for their help and making this project possible.

4
*INDEX*

Sr. Contents Page


No. No.

1 Abstract 6

2 Introduction 7

3 Page Replacement 8
Algorithms

4 Output 11

5 Conclusion 12

6 References 13

5
Abstract
One of the techniques which are used for memory management is paging. In paging, processes are
divided into pages and main memory is divided into frames. Pages of a process are loaded into frames
of main memory when required.

Page Replacement Algorithm is used when a page fault occurs. Page Fault means the page
referenced by the CPU is not present in the main memory.

When the CPU generates the reference of a page, if there is any vacant frame available in the main
memory then the page is loaded in that vacant frame. In another case, if there is no vacant frame
available in the main memory, it is required to replace one of the pages in the main memory with the
page referenced by the CPU.

Page Replacement Algorithm is used to decide which page will be replaced to allocate memory to the
current referenced page.

Different Page Replacement Algorithms suggest different ways to decide which page is to be
replaced. The main objective of these algorithms is to reduce the number of page faults.

6
Introduction

This lesson will introduce you to the concept of page replacement, which is used in
memory management. You will understand the definition, need and various
algorithms related to page replacement.

A computer system has a limited amount of memory. Adding more memory physically
is very costly. Therefore most modern computers use a combination of both hardware
and software to allow the computer to address more memory than the amount
physically present on the system. This extra memory is actually called Virtual Memory.

Virtual Memory is a storage allocation scheme used by the Memory Management


Unit(MMU) to compensate for the shortage of physical memory by transferring data
from RAM to disk storage. It addresses secondary memory as though it is a part of the
main memory. Virtual Memory makes the memory appear larger than actually present
which helps in the execution of programs that are larger than the physical memory.

7
Page Replacement Algorithms:

First In First Out (FIFO) -This algorithm is similar to the operations of


the queue. All the pages are stored in the queue in the order they are
allocated frames in the main memory. The one which is allocated first stays
in the front of the queue. The one which is allocated the memory first is
replaced first. The one which is at the front of the queue is removed at the
time of replacement.

Example: Consider the Pages referenced by the CPU in the order are 6, 7, 8,
9,6,7,1,6,7,8,9,1

• As in the above figure shown, Let there are 3 frames in the memory.
• 6, 7, 8 are allocated to the vacant slots as they are not in memory.
• When 9 comes page fault occurs, it replaces 6 which is the oldest in
memory or front element of the queue.
• Then 6 comes (Page Fault), it replaces 7 which is the oldest page in
memory now.
• Similarly, 7 replaces 8, 1 replaces 9.
• Then 6 comes which is already in memory (Page Hit).
• Then 7 comes (Page Hit).
• Then 8 replaces 6, 9 replaces 7. Then 1 comes (Page Hit).

Number of Page Faults = 9

• While using the First In First Out algorithm, the number of page faults
increases by increasing the number of frames. This phenomenon is
called Belady's Anomaly.
• Let's take the same above order of pages with 4 frames.
8
• In the above picture shown, it can be seen that the number of page
faults is 10.
• There were 9 page faults with 3 frames and 10 page

faults with 4 frames.


• The number of page faults increased by increasing the number of
frames.

Optimal Page Replacement –


In this algorithm, the page which would be used after the longest
interval is replaced. In other words, the page which is farthest to come in the
upcoming sequence is replaced.

Example: Consider the Pages referenced by the CPU in the order are 6, 7,
8, 9,6,7,1,6,7,8,9,1,7,9,6

• First, all the frames are empty. 6, 7, 8 are allocated to the frames (Page
Fault).
• Now, 9 comes and replaces 8 as it is the farthest in the upcoming
sequence. 6 and 7 would come earlier than that so not replaced.
• Then, 6 comes which is already present (Page Hit).
• Then 7 comes (Page Hit).
• Then 1 replaces 9 similarly (Page Fault).
9
• Then 6 comes (Page Hit), 7 comes (Page Hit).
• Then 8 replaces 6 (Page Fault) and 9 replaces 8 (Page Fault).
• Then 1, 7, 9 come respectively which are already present in the memory.
• Then 6 replaces 9 (Page Fault), it can also replace 7 and 1 as no
other page is present in the upcoming sequence.

The number of Page Faults = 8

• This is the most optimal algorithm but is impractical because it is


impossible to predict the upcoming page references.

Least Recently Used –


This algorithm works on previous data. The page which is used the
earliest is replaced or which appears the earliest in the sequence is replaced.

Example: Consider the Pages referenced by the CPU in the order are 6, 7,
8, 9,6,7,1,6,7,8,9,1,7,9,6

• First, all the frames are empty. 6, 7, 8 are allocated to the frames (Page
Fault).
• Now, 9 comes and replaces 6 which is used the earliest (Page Fault).
• Then, 6 replaces 7, 7 replaces 8, 1 replaces 9 (Page Fault).
• Then 6 comes which is already present (Page Hit).
• Then 7 comes (Page Hit).
• Then 8 replaces 1, 9 replaces 6, 1 replaces 7, and 7 replaces 8
(Page Fault).
• Then 9 comes (Page Hit).
• Then 6 replaces 1 (Page Fault).

The number of Page Faults = 12

10
Output:

Fig. 2: Output of First in First out page replacement program

Fig. 3: The output of the optimal page replacement program

Fig. 4: Output of LRU page replacement Program

11
Conclusion:
In the above methods or algorithms .we have found that optimal page replacement algorithm results in
the best algorithm because the average page faults in all three cases with page frame size 2,3 and 4 is less
as compared to FIFO and LRU. Implementation of these algorithms is done as an offline replacement with
demand paging policy. In this analysis, we focus on the offline performance and thus the overhead of the
algorithms is not analyzed

• The objective of page replacement algorithms is to minimize the page faults


• FIFO page replacement algorithm replaces the oldest page in the memory
• Optimal page replacement algorithm replaces the page which will be referred farthest
in the future
• LRU page replacement algorithm replaces the page that has not been used for the
longest duration of time
• LIFO page replacement algorithm replaces the newest page in memory
• Random page replacement algorithm replaces any page at random
• Optimal page replacement algorithm is considered to be the most effective algorithm but
cannot be implemented in practical scenarios due to various limitations

12
References:

➢ Page Replacement Algorithms in Operating Systems

➢ Page Replacement Algorithms | Types of Page ... - EDUCBA

➢ Optimal Page Replacement Algorithm - GeeksforGeeks

➢ Program for Page Replacement Algorithms | Set 2 (FIFO)

13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy