OUTPUT :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
5 3 1
5 2 1
5 2 4
5 2 4
3 2 4
3 2 4
3 5 4
3 5 2
Number of page faults : 6
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 | #include<stdio.h> #include<conio.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; clrscr(); 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;i++) { if(fr[i]==-1) { fr[i]=page[j]; flag2=1; break; } } } if(flag2==0) { fr[top]=page[j]; top++; pf++; if(top>=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]); } |
OUTPUT :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
5 3 1
5 2 1
5 2 4
5 2 4
3 2 4
3 2 4
3 5 4
3 5 2
Number of page faults : 6
can you give me C Program for clock page replacement Algorithm?
this code is not working……… here page faults are 9 but u say 6.
the code in line 18 is wrong……
the correct code will be
for(i=0;i<3;i++)
can uplz give me the algorithm steps for scheduling algorithms(fcfs,sjf,priority,round robin0
and also for page replacement algorithms(fifo,lru)
can ani one help me ….”Write a program that implements the FIFO page- replacement algorithms.First, generate a random page reference string where page numbers range from 0 to 9. Apply the random page-reference string to each algorithm. Implement the replacement algorithms so that the number of page frames can vary from 1 to 7. Assume that demand paging is used. “
anyone help me to write java coding for working set clock page replacement algorithm
line 34 is flag=0;
jab na aaye na to program nai post karna chahiye !!!
ache se padh le phir program post kareooo
You know moron, How to calculate Page fault,if didn’t know then y u The bullshit are u doing…..A Poor Worker Alwaz Blame His Tools .
hey all i need simulation of not recently used page replacement in c or c++
help me in this …….. if some one have then send me on my mail
bsse.2641@gmail.com
Sorry but the program is incorrect it won’t give right answer unless you
Replace line no. 18 from
for(i=0;i<12;i++)
To
for(i=0;i<frsize;i++)
And also there will be a line
Pf++ just before line 33 because initially when we enter pages in frame array the page fault is considered because that page was not present there in the frames.
Check this simple program http://www.javaengineeringprograms.com/first-in-first-out-page-replacement-algorithm-fifo-program-in-java/