-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFIFO_.cpp
More file actions
63 lines (52 loc) · 1.25 KB
/
FIFO_.cpp
File metadata and controls
63 lines (52 loc) · 1.25 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
using namespace std;
int main()
{
int n,array[50],FramesNo,Frame[10];
cout<<"Enter the number of pages: ";
cin>>n;
cout<<"Enter the page number: ";
for(int i=1; i<=n; i++)
cin>>array[i];
cout<<"Enter the number frames: ";
cin>>FramesNo;
for(int i=0; i<FramesNo; i++)
{
Frame[i]=-1;
}
cout<<"\nIncoming\tFrame 1\t\tFrame 2\t\tFrame 3"<<endl;
int i,j,k,s=0,avail,count=0;
for(i=1; i<=n; i++)
{
cout<<" "<<array[i];
avail=0;
for(j=0; j<FramesNo; j++)
{
if(Frame[j]==array[i])
{
avail=1;
}
}
if (avail==0)
{
Frame[s]=array[i];
s=(s+1)%FramesNo;
count++;
for(k=0; k<FramesNo; k++)
{
if(Frame[k]!=-1)
{
cout<<"\t\t "<<Frame[k];
}
else
{
cout<<"\t\t -";
}
}
}
cout<<endl;
}
cout<<"Page Fault is : "<<count<<endl;
cout<<"Page Hit is : " << n-count <<endl;
return 0;
}