22BCE1726 Page Replacement
22BCE1726 Page Replacement
marks]
Instructions
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#define NUM_PROCESSES 3
#define TOTAL_PAGE_REFERENCES 30
#define PAGES_PER_PROCESS 10
int i;
int pageFrames[numFrames];
pageFrames[i] = -1;
lruc[numFrames-1-i]=i;
{
int page = pageReferences[i];
int found = 0;
if (pageFrames[j] == page)
found = 1;
if (strcmp(algorithm, "LRU") == 0)
int temp=lruc[j];
if(lruc[t]<temp)
lruc[t]++;
lruc[j]=0;
break;
if (!found)
pageFaults++;
if (strcmp(algorithm, "FIFO") == 0)
pageFrames[k] = page;
k++;
if(k==4)
k=0;
}
}
int tl=0;
for(int at=0;at<numFrames;at++)
if(lruc[at]==3)
tl=at;
lruc[at]=-1;
pageFrames[tl] = page;
break;
lruc[t]++;
printf("\n");
return pageFaults;
int main()
{
srand(time(NULL));
int processPageReferences[NUM_PROCESSES][PAGES_PER_PROCESS];
int numFrames = 4;
generatePageReferences(i, processPageReferences[i]);
printf("\n");
return 0;
}
OUTPUT: