FIFO-PAGE REPLACEMENT ALGORITHM
ABHISHEK B V (4MN20CS001) Under the guidance of:
RAHUL RAJ H (4MN20CS036) Mr. Bharath Bharadwaj B S,
Assistant Professor,
Dept. of Computer Science & Engineering,
Maharaja Institute of Technology Thandavapura
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 1
CONTENTS
◦ Introduction
◦ Aim
◦ Overview
◦ Requirements
◦ Outcome
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 2
INTRODUCTION
o FIFO stands for "First-In, First-Out," and it is a method used for organizing and manipulating
data or items in a specific order.
o It follows the principle that the first item or data element to enter a system or structure is the
first one to be removed.
o In computing and data management, FIFO is commonly used in various applications, such as
queues, buffers, and scheduling algorithms.
o It ensures that the oldest items or data elements are processed or accessed before newer ones.
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 3
AIM
o The aim of the FIFO (First-In, First-Out) page replacement algorithm is to manage the limited
memory resources of a computer system efficiently by determining which pages should be kept
in memory and which should be replaced when new pages need to be loaded.
o The primary goal of the FIFO algorithm is to ensure that the oldest page, which has been in
memory the longest, is the one that is replaced first when a new page needs to be brought into
memory.
o This principle follows the "First-In, First-Out" concept, where the page that was brought into
memory first is the first one to be removed when the memory is full.
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 4
SOFTWARE REQUIREMENTS
•Programing Language : C/C++ Using OpenGL
• Operating System : Windows /Linux
• Compiler : C/C++ Compiler (GCC)
• IDE : Code Blocks / VS code
DEPT. OF CS&E 5
HARDWARE REQUIREMENTS
• Intel i3 or higher
• 1 GB RAM or more
• Mouse
• Keyboard
• Monitor
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 6
ALGORITHM
Step 1: START
Step 2: Initialize the page Array with a set of page numbers randomly.
Step 3: Create a window using GLUT and initialize the necessary variables.
Step 4: Set up the display, mouse, keyboard, and idle callback functions.
Step 5: Create menus for setting background and tile colors.
Step 6: Enter the GLUT event processing loop.
Step 7: Display the introductory text when the program starts.
Step 8: When the Enter key is pressed, start the animation.
Step 9: Inside the animation loop:
a. Check if there are more pages to process.
b. If there are more pages, increment the step counter.
c. Check if the current page is already in the page buffer.
If yes, increment the hit counter and mark the fault as 0.
d. If the current page is not in the page buffer (page fault):
Determine the position in the buffer where the page should be placed based on the modulo operator (step-hit)%3.
Mark the fault as 1.
e. Update the animation parameters and set the destination position for the current page.
f. Render the animation by calling the display function and update the screen.
Step 10: When the animation is complete, display the total number of page faults.
Step 11: Continue processing events until the program is close
Step 12: STOP
Computer graphics laboratory with mini-Project – 18CSl67 DEPT. OF CS&E 7
FLOW CHART
Computer graphics laboratory with mini-Project – 18CSl67 DEPT. OF CS&E 8
SNAPSHOTS
Fig 3.1: Description Page Fig 3.2: Memory Representation
Computer graphics laboratory with mini-Project – 18CSl67 DEPT. OF CS&E 9
Fig 3.3: Page Replacement event Fig 3.4: Checking for page in Memory
Computer graphics laboratory with mini-Project – 18CSl67 DEPT. OF CS&E 10
Fig 3.4: Number of Page faults
Computer graphics laboratory with mini-Project – 18CSl67 DEPT. OF CS&E 11
OVERVIEW
Here's an overview of how the FIFO page replacement algorithm works:
o Initialization
o Page Request
o Page Replacement
o Update Queue
o Page Fault Count
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 12
OUTCOMES
The outcome of the FIFO (First-In, First-Out) page replacement algorithm can vary depending
on the specific page access pattern and the number of page frames available in the memory.
Here are some possible outcomes
o Demonstration of FIFO algorithm working
o Page Replacement
o Belady's Anomaly
o Page Fault Count
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 13
CONCLUSION
o The FIFO (First-In, First-Out) page replacement algorithm is a simple and straightforward approach used
in memory management.
o It operates on the principle of evicting the oldest page in memory when a page fault occurs. FIFO
maintains a queue or list of pages, with the page at the front of the queue being the oldest.
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 14
Any suggestions!
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 15
Thank You Listeners!
COMPUTER GRAPHICS LABORATORY WITH MINI-PROJECT – 18CSL67 DEPT. OF CS&E, MITT 16