Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What would be the algorithm for the following C code? Can I just get pseudocode, please? int * FIFOAlgorithm( int n, int *a, int number)
What would be the algorithm for the following C code? Can I just get pseudocode, please?
int* FIFOAlgorithm(int n, int *a, int number) { int i,j,k,frame[number],available,pageFault=0; static int PageFaultcount[] = {0,0,0,0,0}; for(i=0;ifor(i=1;i<=n;i++) { if(i%2000 == 0) { PageFaultcount[((i/2000)-1)] = pageFault; // printf(" FIFO : %d = %d", i, pageFault); } available=0; for(k=0;k if(frame[k]==a[i]) available=1; if (available==0){ frame[j]=a[i]; j=(j+1)%number; pageFault++; } } //printf(" FIFO : Total no of page faults %d",pageFault); return PageFaultcount; } int isHit(int data, int nf, int *p) { int hit=0,j; for( j=0; j if(p[j]==data) { hit=1; break; } } return hit; } int getHitIndex(int data, int nf, int *p) { int hitindex; int k; for( k=0; k if(p[k]==data) { hitindex=k; break; } } return hitindex; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started