OUTPUT :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
2 5 1
2 5 1
2 5 4
2 5 4
3 5 4
3 5 2
3 5 2
3 5 2
no of page faults : 4
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 64 65 66 67 68 69 | #include<stdio.h> #include<conio.h> int fr[3]; void main() { void display(); int p[12]={2,3,2,1,5,2,4,5,3,2,5,2},i,j,fs[3]; int index,k,l,flag1=0,flag2=0,pf=0,frsize=3; clrscr(); for(i=0;i<3;i++) { fr[i]=-1; } for(j=0;j<12;j++) { flag1=0,flag2=0; for(i=0;i<3;i++) { if(fr[i]==p[j]) { flag1=1; flag2=1; break; } } if(flag1==0) { for(i=0;i<3;i++) { if(fr[i]==-1) { fr[i]=p[j]; flag2=1; break; } } } if(flag2==0) { for(i=0;i<3;i++) fs[i]=0; for(k=j-1,l=1;l<=frsize-1;l++,k--) { for(i=0;i<3;i++) { if(fr[i]==p[k]) fs[i]=1; } } for(i=0;i<3;i++) { if(fs[i]==0) index=i; } fr[index]=p[j]; pf++; } display(); } printf("\n no of page faults :%d",pf); getch(); } void display() { int i; printf("\n"); for(i=0;i<3;i++) printf("\t%d",fr[i]); } |
OUTPUT :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
2 5 1
2 5 1
2 5 4
2 5 4
3 5 4
3 5 2
3 5 2
3 5 2
no of page faults : 4
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
June 4th, 2010 at 4:45 pm
good job
if you want I send you my project in cpp.
June 19th, 2010 at 8:55 pm
good job
can u send me your projuct… I think that it can help me
thainks a lot
November 7th, 2010 at 7:37 pm
Hi
This pgm sounds good. If u have page replacement algorithm project can u
u mail to the above e mail address
February 18th, 2011 at 8:40 pm
why only 4 page faults? i think there are 7 page faults…
April 22nd, 2011 at 4:20 pm
paul u r correct..there r 7 page faults..he hasnt included the initial page faults while inserting the pages initially in d stack
May 8th, 2011 at 1:19 am
this code has 6 page faults…
September 23rd, 2011 at 8:27 pm
yup akansha that’s correct…………he hasn’t included d initial page faults
October 23rd, 2011 at 8:28 am
ya dis pogram is crct but page faults are 7 he did not include first 3