Develop a C program to implement the page replacement algorithms (FIFO, Optimal, LRU and LFU) using linked list.
Algorithm:
Implement the following modules and its operations using linked list.
Read module:
- Read the number of frames.
- Read the number of frames required by the process N.
- Read the reference string for allocation of page frames.
Page replacement module:
FIFO REPLACEMENT
- Allocate the first N pages into the frames and increment the page faults accordingly.
- When next frame in the reference string is not already available in the allocated list do
- Look for the oldest one in the allocated frames and replace it with the next page
- Increment the page fault whenever a frame is replaced.
OPTIMAL REPLACEMENT
- Allocate the first N pages into the frames and increment the page faults accordingly.
- When next frame in the reference string is not already available in the allocated list do
- Look for a frame in the reference string will not be used for longest period of time.
- Increment the page fault whenever a frame is replaced. (Hint: Locate the position of each allocated frame in the reference string; identify a frame for replacement with largest index position)
- Display the allocated frame list after every replacement.
LRU REPLACEMENT
- Allocate the first N pages into the frames and increment the page faults accordingly.
- When next frame in the reference string is not already available in the allocated list do
- Look for a frame which is not used recently.
- Increment the page fault whenever a frame is replaced.
- Display the allocated frame list after every replacement
LFU REPLACEMENT
- Allocate the first N pages into the frames and increment the page faults accordingly.
- When next frame in the reference string is not already available in the allocated list do
- Look for a frame which is least frequently used.
- Increment the page fault whenever a frame is replaced.
- Display the allocated frame list after every replacement
Sample input & output:
PAGE REPLACEMENT ALGORITHMS
- READ_INPUT
- FIFO
- OPTIMAL
- LRU
- LFU
- EXIT
Enter your option: 1
Enter the number of free frames: 10
Enter the number of frames required by the process: 4
Enter the reference string: 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
Enter your option: 2
FIFO Page Replacement Algorithm
The reference string: 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
Page ref memory PF
7 7 1
- 7 0 2
- 7 0 1 3
- 7 0 1 2 4
0 7 0 1 2
3 3 0 1 2 5
| 7 | 7 | 7 | 7 | 3 | 3 | 3 | 3 | 2 | 2 |
| 0 | 0 | 0 | 0 | 4 | 4 | 4 | 4 | 7 | |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | ||
| 2 | 2 | 2 | 2 | 1 | 1 | 1 |
Total Number of Page Faults: 10

![[Solved] UCS1411 Exercise 10-Page Replacement Algorithms](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] UCS1411 Exercise 5-InterProcess Communications on Shared Memory](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.