Page Replacement Algorithms: A Project Report On
Page Replacement Algorithms: A Project Report On
A
Project Report
On
“Page Replacement Algorithms”
For the requirement of partial fulfillment curriculum of
DIPLOMA IN COMPUTER ENGINEERING
Submitted by:
Mr. Bhushan Siddhappa Karguppi
Mr. Shankar Maruti Morti
Mr. Shreyash Tanaji Magdum
Mr. Prathmesh Yashwant Sardesai
Mr. R. B. More
Certificate
This is to certify that the following students of Fifth semester of Diploma in
COMPUTER ENGINEERING of Institute SANT GAJANAN RURAL
POLYTECHNIC, MAHAGAON-416503.(CODE-0965) has completed micro-project
on “Page Replacement Algorithms” satisfactory in subject „OSY‟ subject code
(22516) for academic year 2023 to2024 as prescribed in the curriculum.
ENROLLMENT
ROLL EXAM. NAME OF STUDENT
NO NO SEAT NO
22 2109650147 Bhushan Karguppi
33 2109650173 Shankar Morti
35 2109650175 Shreyash Magdum
28 2109650163 Prathmesh Sardesai
1.0 Rationale
Memory management is the most important part of operating system in which all activities related to the memory
are perform . The replacement of page is the main concept. Pages is required to be in the main memory . Computer
system objective is to execute program of different sizes. The program should be in main memory when program
is executed. But main memory has limited size to accommodate programs which is large. Execution of program
that may not be entirely in main memory is called virtual memory. Virtual memory paved the way to execute
program that is larger than main memory. The process in which we provisionally moves process from primary
memory to the hard disk or secondary memory, so that the memory available for other processes, which is known
as swapping .
On operating systems which use paging for memory management, it is needed a page replacement algorithm to
decide which pages to replace when a new page is entered. Good replacement can reduce the cost of page fault
that result in higher performance of the system.
Page Fault occurs when a process references to a page that is not present in the main memory and needs to be
through from secondary memory. When a program currently executing, accessing a memory page that is mapped
to the virtual address space, but is not loaded into physical memory. Because actual physical memory is much
smaller than virtual memory, a page fault occurs. In this case, the operating system may have to replace one of
the existing pages with the new page it needs. There are several page replacement algorithms for this replacement.
One of them is the random page replacement algorithm
2.0 Aim
To study different types of page replacement algorithm.
4
4.0 Literature review
There are several algorithms of page replacement proposed by experts, namely :
1. First in First out (FIFO): This is the simplest page changing algorithm. In this algorithm, the operating system
keeps track of all the pages in memory that are in the queue, namely page that has been in front of the queue the
longest. When a page has to be replaced the page at the front of the queue is chosen to be deleted. An average of
hit ratio of 50 percent is reported by FIFO algorithm. The advantages and disadvantages of FIFO algorithm: Easy
to understand, very easy to be implemented, Performance not always good.
2. Optimal Page Replacement: In this algorithm, pages are replaced which will not be used for the next longest
duration of time. Optimal page replacement is a good algorithm, but it is impossible to implement practically,
because the operating system will not know the next request. The use of this algorithm is to create benchmarks
so that other replacement algorithms can be analyzed against this algorithm. On this algorithm, system select
victim whole reference is furthest. This algorithm has the best page fault behavior reported.
3. Least Recently Used: In this algorithm, the page will be replaced the least used (least recently used). An average
of 60 % hit ratio is reported by LRU algorithm. This algorithm selects the victim page as that which is not been
demanded for access for along time.
4. Random Page Replacement Algorithm: In this algorithm, the operating system will keep track of all the pages
in memory which are marked as the next replaced slot. And the selection of which slots to replace is done
randomly. Page replacement algorithm depends on the following parameters: Page fault rate, indicates by how
many misses occur for a set of page reference. The minimal the page fault rate, the higher the efficiency of the
algorithm. Hit rate, indicates how many hits occur on the page. The higher hit rate, the higher the efficiency of
the algorithm.
1. Methodology
Focus on selection of appropriate topic for Micro project.
Select the topic Batch Operating System
To meet the subject teacher and take guidelines about it.
Searching the information related to the topic of micro-project.
Start the procedure for project and making soft copy of project report.
We organize all information about our topic in proper manner.
Show the soft copy of the project report to subject teacher and make corrections in it.
Submit the hard copy of the project report to the subject teacher.
5
4.0 Actual Resource Required
Sr. Name of Resource Specification Quantity Remarks
No required
1 Computer system Intel (R) Core (TM) 1 used
i31450 CPU32 bit
operating System
2 Operating System Windows 10 1 used
13-09- 27-09-
2023 2023
6 Submit project Bhushan Karguppi
29-10- 02-11-
2023 2023
6
5.0Resource Required
7
Part – B Micro-Project Report
Title: - Calculate Page Fault Of Using Different Page Replacement Algorithms
1.0 Rationale
An Operating System is basically a system program that controls the execution of application programs and acts
as an interface between applications and the computer hardware. It manages the computer system the computer
system resources to be used in an efficient manner.
8
Page replacement is needed in the operating systems that use virtual memory using Demand Paging. As we
5.1
knowPage Replacement
that in Algorithms
Demand paging, only a set of pages of a process is loaded into the memory. This is done so that we
can have more processes in the memory at the same time.
When a page that is residing in virtual memory is requested by a process for its execution, the Operating System
needs to decide which page will be replaced by this requested page. This process is known as page replacement
and is a vital component in virtual memory management.
5.3.1 First In First Out (FIFO)
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:- Consider page reference string 1, 3, 0, 3, 5, 6, 3 with 3 page frames. Find the number of page
faults.
9
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.
Advantages
Disadvantages
Poor performance
Doesn’t use the frequency of the last used time and just simply replaces the oldest page.
Suffers from Belady’s anomaly.
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, 3 with 4 page frame. Find number of
page fault.
10
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.
Advantages
Excellent efficiency
Less complexity
Easy to use and understand
Simple data structures can be used to implement
Used as the benchmark for other algorithms
Disadvantages
11
-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.
Advantages
Disadvantages
This is the Last in First Out algorithm and works on LIFO principles. In this algorithm, the newest page is
replaced by the requested page. Usually, this is done through a stack, where we maintain a stack of pages
currently in the memory with the newest page being at the top. Whenever a page fault occurs, the page at the
top of the stack is replaced.
12
Example: Let’s see how the LIFO performs for our example string of 3, 1, 2, 1, 6, 5, 1, 3 with 3-page frames:
Initially, since all the slots are empty, page 3,1,2 causes a page fault and takes the empty slots.
Page faults = 3
Page faults = 3
When page 6 comes, the page fault occurs and page 2 is removed as it is on the top of the stack and is
the newest page.
Page faults = 4
When page 5 comes, it is not in the memory, which causes a page fault, and hence page 6 is
removed being on top of the stack.
Page faults = 5
When page 1 and page 3 come, they are in memory already, hence no page fault occurs.
As you may notice, this is the same number of page faults as of the Optimal page replacement algorithm. So we
can say that for this series of pages, this is the best algorithm that can be implemented without the prior
knowledge of future references.
Advantages
Simple to understand
Easy to implement
13
No overhead
Disadvantages
Does not consider Locality principle, hence may produce worst performance
The old pages may reside in memory forever even if they are not used
This algorithm, as the name suggests, chooses any random page in the memory to be replaced by the requested
page. This algorithm can behave like any of the algorithms based on the random page chosen to be replaced.
Example: Suppose we choose to replace the middle frame every time a page fault occurs. Let’s see how our
series of 3, 1, 2, 1, 6, 5, 1, 3 with 3-page frames perform with this algorithm:
Initially, since all the slots are empty, page 3,1,2 causes a page fault and takes the empty slots
Page faults = 3
Page faults = 3
When page 6 comes, the page fault occurs, we replace the middle element i.e 1 is removed.
Page faults = 4
When page 5 comes, the page fault occurs again and middle element 6 is removed
14
Page faults = 5
When page 1 comes, there is again a page fault and again the middle element 5 is removed
Page faults = 6
As we can see, the performance is not the best, but it's also not the worst. The performance in the random
replacement algorithm depends on the choice of the page chosen at random.
Advantages
Disadvantages
Can not be analysed, may produce different performances for the same series
Can suffer from Belady’s anomaly
15
Action Plan Implementation
13-09- 27-09-
2023 2023
6 Submit project Bhushan Karguppi
29-10- 02-11-
2023 2023
16
Conclusion
Reference
www.guru.com
www.geeksforgeek.com
www.javatpoint.com
17