-
Notifications
You must be signed in to change notification settings - Fork 0
/
fifo.c
41 lines (41 loc) · 954 Bytes
/
fifo.c
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
#include <stdio.h>
void main()
{
printf("enter the number of pages \n");
int n;
scanf("%d", &n);
printf("enter the page numbers");
int i, a[10];
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
printf("enter the number of frames\n");
int no;
scanf("%d", &no);
int frame[10];
for (i = 0; i < no; i++)
frame[i] = -1;
int j = 0;
printf("ref string \t page frame \n";
int k, count = 0;
for (i = 1; i <= n; i++)
{
printf("%d\t\t", a[i]);
int avail = 0;
for (k = 0; k < no; k++)
{
if (frame[k] == a[i])
avail = 1;
if (avail == 0)
{
frame[j] = a[i];
j = (j + 1) % no;
count++;
for (k = 0; k < no; k++)
{
printf("%d\t", frame[k]);
}
}
}
printf("\n");
}
}