0% found this document useful (0 votes)
25 views7 pages

Page Replacement Algorithm Presentation

Uploaded by

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

Page Replacement Algorithm Presentation

Uploaded by

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

Simple Page Replacement

Algorithm
FIFO (First-In-First-Out) with Demo
Code
Introduction to Page Replacement
• In computer operating systems, page
replacement is the process of replacing a page
in memory when a page fault occurs. When
the memory is full and a new page needs to
be loaded, the system needs to decide which
page to remove.
FIFO Page Replacement Algorithm
• FIFO (First-In-First-Out) is a page replacement
algorithm that removes the oldest page in
memory when a new page is needed. The
pages are maintained in a queue, and the first
page that was loaded into memory is the first
to be replaced.
Steps of FIFO Algorithm
• 1. Initialize an empty frame for pages.
• 2. For each page in the reference string:
• a. Check if the page is already in memory.
• b. If not, check if there's an empty frame.
• c. If all frames are full, replace the oldest
page.
• 3. Count the number of page faults.
Demo Code in C
• #include <stdio.h>
• int main() {
• int total_pages, total_frames, pages[30],
frames[10], page_faults = 0;
• // Input, Initialize frames, FIFO logic...
• // Output the frames and total page faults
• }
• // Complete code shown earlier in the
explanation.
Example Output
• Input:
• Number of pages: 7
• Page reference string: 1 3 0 3 5 6 3
• Number of frames: 3

• Output:
• Total Page Faults: 5
Conclusion
• The FIFO page replacement algorithm is
simple and easy to implement.
• However, it may not always be the most
efficient, as it does not consider the frequency
of use of pages. Other algorithms, such as LRU
(Least Recently Used), can provide better
performance.

You might also like