0% found this document useful (0 votes)
5 views

FIFOPageReplacementAlgorithm

The document contains a C program implementing the FIFO page replacement algorithm. It prompts the user for the number of frames and a reference string, then processes the references while tracking page faults. The program outputs the number of page faults encountered during execution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

FIFOPageReplacementAlgorithm

The document contains a C program implementing the FIFO page replacement algorithm. It prompts the user for the number of frames and a reference string, then processes the references while tracking page faults. The program outputs the number of page faults encountered during execution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

/*FIFOPageReplacementAlgorithm*/

#include<stdio.h>
#include<conio.h>
int i,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1;
void main()
{
printf("\n\t\t\tFIFO PAGE REPLACEMENT ALGORITHM");
printf("\nEnter no.of frames.....");
scanf("%d",&nof);
printf("Enter number of reference string..\n");
scanf("%d",&nor);
printf("\nEnter the reference string..");
for(i=0;i<nor;i++)scanf("%d",&ref[i]);
printf("\nThe given referencestring:");
for(i=0;i<nor;i++)
printf("%4d",ref[i]); for(i=1;i<=nof;i+
+)
frm[i]=-1;
printf("\n"); for(i=0;i<nor;i+
+)
{
flag=0;
printf("\n\tReferencenp%d->\t",ref[i]);
for(j=0;j<nof;j++)
{
if(frm[j]==ref[i])
{
flag=1;
break;
Page29
}}
if(flag==0)
{
p
f
+
+
;

v
i
c
t
i
m
+
+
;
victim=
victim
%nof;
frm[vic
tim]=re
f[i];
for(j=0;
j<nof;j
++)
printf("
%4d",f
rm[j]);
}
}
printf("\n\n\t\tNo.of pages faults...%d",pf);
}

You might also like