FIFO Page Replacement Algorithm
FIFO Page Replacement Algorithm
1. Aim
To simulate the FIFO page replacement algorithm and display the frame contents in a tabular form for each page reference.
2. Objective
-
To understand FIFO page replacement
-
To observe page hits and faults
-
To display memory frame status step-by-step
3. Theory
3.1 Virtual Memory
Virtual memory allows execution of processes larger than physical memory by dividing memory into pages.
When a required page is not in memory, a page fault occurs and the OS must replace an existing page.
3.2 FIFO Page Replacement Algorithm
FIFO (First-In First-Out) replaces the page that entered memory earliest, irrespective of how frequently or recently it was used.
➡ Conceptually simple but may suffer from Belady’s anomaly.
3.3 Key Characteristics
| Feature | Description |
|---|---|
| Replacement policy | Oldest page |
| Data structure | Queue |
| Implementation | Simple |
| Drawback | Belady’s anomaly |
4. Algorithm (FIFO)
-
Initialize all frames to
-1 -
Maintain a pointer (
next) to track the oldest page -
For each page reference:
-
If page is found → Hit
-
Else → Fault
-
Replace frame at
next -
Move
nextcircularly
-
-
-
Count total page faults
5. Example
Page Reference String
Number of Frames
6. Expected Tabular Format
| Page | Frame 1 | Frame 2 | Frame 3 | Status |
|---|---|---|---|---|
| 7 | 7 | - | - | Fault |
| 0 | 7 | 0 | - | Fault |
| 1 | 7 | 0 | 1 | Fault |
| 2 | 2 | 0 | 1 | Fault |
| 0 | 2 | 0 | 1 | Hit |
| 3 | 2 | 3 | 1 | Fault |
| 0 | 2 | 3 | 0 | Fault |
| 4 | 4 | 3 | 0 | Fault |
7. C Program
8. Sample Input
9. Sample Output (Formatted)
10. Observations
-
FIFO uses a circular pointer
-
Frame replacement is independent of usage
-
Recently used pages may be replaced
11. Advantages
-
Simple and fast
-
Easy to implement
12. Disadvantages
-
Suffers from Belady’s anomaly
-
Not optimal for real systems
13. Result
The FIFO page replacement algorithm was successfully implemented and the frame contents were displayed in a tabular format for each page reference.
Comments
Post a Comment