Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. This scheme permits the physical address space of a

Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. This scheme permits the physical address space of a process to be non contiguous.

Given below is one of the page replacement algorithm program, you are to first identify which algorithm (FIFO, Optimal Page Replacement, Least frequently used) is implemented in given c-code. Please consider following reference string for this page replacement algorithm (1,2,3 5,1,3,4,5,6,1,5,3,2) with 4 page/frame size.

There are some errors in this program, you have to correct it first, and then explain compiled output with each miss or hit condition.

Note: Show complete procedure with detail steps/screenshots with your arid number.

#include

void main()

{

int pos,c,m,maxi,i,k,nf,count,j=0,pf=0,np=0;

printf("enter no. of pages");

scanf("%d",&np);

int s[np];

printf("Enter pages sequence : ");

for(i=0;i

scanf("%d",&s[i]);

printf("enter the no. of frames");

scanf("%d",&nf);

int q[nf],q1[nf];

for(i=0;i

q[i]=-1;

for(i=0;i

{maxi=0;

for(m=0;m

q1[m]=-1;

c=0;

for(k=0,k

if(s[i]==q[k])

c++;

if(c==0)

{

if(q[nf-1]==-1)

{

q[j]=s[i];

pf++;

j++;

for(k=0;k

printf("%d\t",q[k]);

printf("-> %d ",pf);

}

else {

for(j=0;j

for(m=i+1,count=0;m

if(q[j]==s[m] && q1[j]==-1)

q1[j]=count;

if(q1[j]==-1){

for(m=0;m

if(q[j]==s[m] && q1[j]==-1)

q1[j]=count;

}

}

for(m=0;m

if(q1[m]>maxi){

maxi=q1[m];

pos=m;}

q[pos]=s[i];pf++;

for(m=0;m

printf("%d ",q[m]);

printf("-> %d ",pf);

}

}printf("the total no. of page faults are: %d",pf);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago