Home / C / C program to replace pages for given frame-buffer using FCF technique

C program to replace pages for given frame-buffer using FCF technique

 

C program for replacing pages in a given frame using FCFS scheduling technique.

#include "stdio.h"
#include "conio.h"
int min(int [],int);
void main()
{
int fz,count,f[10],n,p[30],fault=0,i,j;

clrscr();
printf("\n enter the size of frame : ");
scanf("%d",&fz);
printf("\n enter the number of pages: ");
scanf("%d",&n);
printf("\n enter all the page number\n");

for(i=0;i<n;i++)
scanf("%d",&p[i]);
for(i=0;i<n;i++)
{
count=0;
for(j=0;j<fz;j++)
if(p[i]==f[j])
count++;
if(count==0)
{
f[fault%fz]=p[i];
fault++;
}
}
for(i=0;i<fz;i++)
printf("frame[%d]=%d\n",i+1,f[i]);
printf("page fault=%d",fault);
getch();
}

 

OUTPUT :

 
 
Tags: c program for page replacement , FCFS scheduling to solve page replacement in c

 

Check Also

How to Solve Linear Equation in One Variable In C Programming?

C Program to Solve any Linear Equation in One Variable Find complete C program to ...

Leave a Reply

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