Random Page Replacement Algorithm
Random Page Replacement Algorithm
1. Aim
To implement the Random Page Replacement Algorithm and display the frame contents after each page reference.
2. Objective
-
To understand the working of Random page replacement
-
To replace a page using a random selection strategy
-
To display the frame table after each page arrival
-
To analyze page hits and page faults
-
To compare its behavior with FIFO, LRU, and Optimal
3. Theory
The Random Page Replacement Algorithm replaces a page selected randomly from the available frames when a page fault occurs and no empty frame is available.
🔹 Key Idea:
“When replacement is needed, choose any frame randomly.”
Unlike:
-
FIFO → replaces oldest page
-
LRU → replaces least recently used page
-
LFU → replaces least frequently used page
-
Optimal → replaces page used farthest in future
Random replacement does not consider past or future information.
4. Characteristics
| Feature | Description |
|---|---|
| Replacement Strategy | Random selection |
| Uses Past Information | ❌ No |
| Uses Future Information | ❌ No |
| Complexity | Very simple |
| Practical Use | Rare in real OS |
| Performance | Unpredictable |
5. Algorithm
-
Initialize all frames as empty (
-1) -
For each page reference:
-
If page exists → Hit
-
Else:
-
If empty frame exists → place page
-
Else:
-
Generate random index between
0andf-1 -
Replace page at that index
-
-
-
-
Display frame table after each reference
-
Count page faults
6. C Program (Random Page Replacement)
7. Sample Input
8. Sample Output (Example Run)
⚠️ Note: Output varies because replacement is random.
9. Observations
-
Page faults vary on each execution
-
No tracking of recency or frequency
-
Performance is unpredictable
10. Advantages
✔ Very simple to implement
✔ Low overhead
✔ No need to maintain extra data structures
11. Disadvantages
❌ Poor performance in many cases
❌ Unpredictable results
❌ Not suitable for real systems
❌ May replace frequently used pages randomly
12. Comparison with Other Algorithms
| Algorithm | Basis of Replacement |
|---|---|
| FIFO | Oldest page |
| LRU | Least recently used |
| LFU | Least frequently used |
| Optimal | Farthest future use |
| Random | Random selection |
13. Result
The Random Page Replacement Algorithm was successfully implemented and simulated. The frame table was displayed after each page reference, and total page faults were calculated.
Comments
Post a Comment