
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
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 (19-ARID-1041).
|
|
|
#include <stdio.h> |
void main() |
|
{ |
|
intpos,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 :\n"); |
|
for(i=0;i<np;i++) |
|
scanf("%d",&s[i]); |
|
printf("enter the no. of frames"); |
|
scanf("%d",&nf); |
|
int q[nf],q1[nf]; |
|
for(i=0;i<nf;i++) |
|
q[i]=-1; |
|
for(i=0;i<np;i++) |
|
{maxi=0; |
|
for(m=0;m<nf;m++) |
|
q1[m]=-1; |
|
c=0; |
|
for(k=0,k<nf;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<nf;k++) |
|
printf("%d\t",q[k]); |
|
printf("-> %d\n",pf); |
|
} |
|
else { |
|
for(j=0;j<nf;i++){ |
|
for(m=i+1,count=0;m<np;m++,count++) |
|
if(q[j]==s[m] && q1[j]==-1) |
|
q1[j]=count; |
|
if(q1[j]==-1){ |
|
for(m=0;m<i;m++,count++) |
|
if(q[j]==s[m] && q1[j]==-1) |
|
q1[j]=count; |
|
} |
|
} |
|
for(m=0;m<nf;m++) |
|
if(q1[m]>maxi){ |
|
maxi=q1[m]; |
|
pos=m;} |
|
q[pos]=s[i];pf++; |
|
for(m=0;m<nf;m++) |
|
printf("%d ",q[m]); |
|
printf("-> %d\n",pf); |
|
|
|
|
|
|
|
} |
|
}printf("the total no. of page faults are: %d",pf); |
|
} |

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 4 images

- Assume we have a free space management system as described in the book, for example one used to provide us with virtual addresses on the heap (with physical addresses handled by a much simpler system since we assume paging). Assume the system uses the following very simple rules; A memory request traverses the free list, and finds the first block large enough to handle the request (i.e., the first fit algorithm from the book). It then: Splits the block into 2 pieces: The first piece will be the requested size + 1k (for a header). The second will be the remaining The first piece will be returned to the caller, but the address returned will be the address of the memory for the user, that is the header + 1k The second will be put back into the linked list If there's insufficient contiguous memory, the allocation will fail (return 0) Free memory is stored as a linked list in address order Assume we start with a single contiguous block of FREE memory of size 64k starting at location…arrow_forwardtry to ans in 30 minarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





