Skip to main content

Posts

Showing posts with the label mfu algorithm

Write the simulation program for demand paging and show the page scheduling and total number of page faults according to MFU page replacement algorithm. Assume the memory of n frames.

Write the simulation program for demand paging and show the page scheduling and total number of page faults according to MFU page replacement algorithm. Assume the memory of n frames. Program: #include <stdio.h> #include <stdlib.h> int stack[5], x,f,al[10],flag; void selectPage(int s){ int i,j; for(i=0;i<x;i++){ if(stack[i]==s){ for(j=i;j<x;j++){ stack[j]=stack[j+1]; } } } stack[x]=s; } int searchPage(int s){ int i; for(i=0;i<f;i++){ if(al[i]==s){ return i; } } return -1; } void main(){ setbuf(stdout,NULL); int i,j,pg[50],tp,pf; printf("\nEnter the number of frames:"); scanf("%d",&f); printf("\nEnter the total pages:"); scanf("%d",&tp); printf("\nEnter the page string:"); for(i=0;i<tp;i++){ scanf("%d",&pg[i]); } pf=0; x=-1; flag=-1; for(i=0;flag!=f;i++){ if(searchPage(pg[i])==-1){ pf++; stack[++x]=pg[i]; al[++flag]=pg[i]; }else...