First In First Out Page Replacement Algorithm

C program for First In First Out Page Replacement Algorithm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "stdio.h"
int fr[3];
 
void main()
{
	void display();
	int i,j,page[12]={2,3,2,1,5,2,4,5,3,2,5,2};
	int flag1=0,flag2=0,pf=0,frsize=3,top=0;
	for(i=0;i<3;i++)
	{
		fr[i]=-1;
	}
	for(j=0;j<12;j++)
	{
		flag1=0;
		flag2=0;
		for(i=0;i<12;i++)
		{
			if(fr[i]==page[j])
			{
				flag1=1;
				flag2=1;
				break;
			}
		}
		if(flag1==0)
		{
			for(i=0;i=frsize)
				top=0;
		}
		display();
	}
	printf("Number of page faults : %d ",pf);
	getch();
}
void display()
{
	int i;
	printf("\n");
	for(i=0;i<3;i++)
		printf("%d\t",fr[i]);
}
Arun

2 thoughts on “First In First Out Page Replacement Algorithm

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in