0% found this document useful (0 votes)
8 views1 page

Exp 5 Fifo

Uploaded by

itsme31121999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Exp 5 Fifo

Uploaded by

itsme31121999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>

void main() {
int i, j, k, f, pf = 0, count = 0, rs[25], m[10], n;

printf("Enter the length of reference string: ");


scanf("%d", &n);

printf("Enter the reference string: ");


for (i = 0; i < n; i++)
scanf("%d", &rs[i]);

printf("Enter the number of frames: ");


scanf("%d", &f);

for (i = 0; i < f; i++)


m[i] = -1;

printf("\nThe Page Replacement Process is -- \n");

for (i = 0; i < n; i++) {


for (k = 0; k < f; k++) {
if (m[k] == rs[i])
break;
}

if (k == f) {
m[count++] = rs[i];
pf++;
}

for (j = 0; j < f; j++)


printf("\t%d", m[j]);

if (k == f)
printf("\tPF No. %d", pf);

printf("\n");

if (count == f)
count = 0;
}

printf("\nThe number of Page Faults using FIFO are %d", pf);


}

You might also like