Fall 2024 - CS604P - 2
Fall 2024 - CS604P - 2
(CS604P)
Assignment # 02
Fall 2024
Question 1: 20 Marks
Write a c program to implement LRU Page Replacement algorithm. If we consider the recent
past as a predictor of the near future, we will replace the page that has been unused for the
longest time. Pages that are rarely used are likely to remain infrequently accessed in the
future.
Also write and display your Student ID in the program at the end of the program output same
as shown in the figure.
Solution:
#include <stdio.h>
#include <stdlib.h>
if (!found) {
int lruIndex = getLRUIndex(time, numFrames);
frames[lruIndex] = page;
time[lruIndex] = i;
pageFaults++;
int main() {
int numFrames, numPages;
int reference[numPages];
int frames[numFrames];
Output: