#include #include #include #include #include //NOTES from the class, for FIFO you WILL NEED to use queue implementation. (this needs to be a priority queue, with 'decresea key') //priority queues...

I need help ASAP my final grade depends on this. Programming language is in C


#include #include #include #include #include //NOTES from the class, for FIFO you WILL NEED to use queue implementation. (this needs to be a priority queue, with 'decresea key') //priority queues differ from notmal queues in that normal queues can only 'enqueue' and 'dequeue', while priority queues can do more. int assignIntVar(char* prompt) { int val; printf("%s", prompt); scanf("%d", &val); printf("\n"); return val; } double assigndDoubleVar(char* prompt) { double val; printf("%s", prompt); scanf("%f", &val); printf("\n"); return val; } // u /* Print a uniformly distributed random integer in range [m,M) */ int UniDistRNG(int M, int m) { int randNum; randNum = rand() % (M-m) + m; return randNum; } double dbl_Rand(double min, double max) { double randNum; double range = (max-min); double div = RAND_MAX/range; randNum = min + (rand()/div); return randNum; } void GenerateRS(FILE *RS) { int P; int e; int m; double t; /*======================== Assigning the variables via input ===============*/ //P = assignIntVar("Type the desired size of Virtual Memory (P): "); //Virtual Memory of a process consists of P pages, numbered 0 through P-1 //m = assignIntVar("Type the desired Rate of Motion (m): "); //rate of motion, Each page in L is typically referenced only a few hundred times. Ex: m = 200 //e = assignIntVar("Type the desired size of the Locus (e): "); //Small integer representing current locus //t = assigndDoubleVar("Type the desired probability of transition (t): "); //A very small fraction /*==========================================================================*/ /*== Assigning Fixed values ==*/ //These values are the test values from Scenario #1 in the assignment 3 page P = 1048576; //2^20 m = 20; e = 10; t = 0.001; /*===================================================*/ int s = 0; //Starting location, must be initially 0 int countGeneratedNumbers = -1; //starting at -1 to have 0 be the index of the first number while (countGeneratedNumbers < 1000000)="" {="" double="" r;="" int="" numtoappend;="" int="" i;="" for="" (i="0;" i="">< m;="" i++)="" {="" numtoappend="UniDistRNG((s+e),s);" process="" is="" executing="" within="" current="" locus="" fprintf(rs,="" "%d\n",="" numtoappend);="" appends="" a="" number="" to="" the="" file="" in="" a="" new="" line="" countgeneratednumbers++;="" adds="" 1="" to="" the="" counter="" of="" generated="" numbers="" }="" r="dbl_Rand(0.000,1.000);" generate="" random="" number="" r="" in="" the="" range="" [0:1)="" if="" (r="">< t)="" process="" transitions="" to="" a="" new="" location="" s="" {="" s="UniDistRNG((P-e),0);" l="" moves="" to="" a="" new="" location,="" s,="" within="" [0="" :="" p="" -="" e],="" chosen="" at="" random="" i="" used="" the="" line="" below="" to="" see="" how="" often="" s="" was="" transitioning.="" the="" reason="" why="" t="" is="" so="" small="" is="" because="" transitions="" should="" be="" rare,="" so="" there="" should="" be="" gaps="" of="" 1000="" numbers="" at="" least.="" printf("process[%d]="" has="" transitioned="" to="" a="" the="" new="" location:="" %d\n",countgeneratednumbers,="" s);="" }="" else="" {="" s="(s+1)%P;" i'm="" guessing="" this="" is="" to="" prevent="" s="" from="" going="" over="" p,="" rare="" as="" that="" may="" be.="" }="" }="" }="" int="" main="" ()="" {="" time_t="" t;="" srand((unsigned)="" time(&t));="" creating="" the="" seed="" for="" the="" randomizer="" int="" m[10];="" physical="" memory="" of="" the="" system="" is="" approximated="" as="" an="" integer="" array="" m[10]="" file="" *fp;="" reference="" string="" file="" char="" *filename="referenceString.txt" ;="" fp="fopen(filename," "w");="" open="" file="" in="" write="" mode.="" if="" a="" file="" by="" that="" name="" doesn't="" exist="" 'w'="" creates="" it,="" if="" a="" file="" by="" that="" name="" already="" exists,="" 'w'="" clears="" out="" all="" the="" content="" in="" it.="" if="" (fp="" !="NULL)" {="" printf("file="" created="" successfully!\n");="" }="" else="" {="" printf("failed="" to="" create="" the="" file.\n");="" exit="" status="" for="" os="" that="" an="" error="" occurred="" return="" -1;="" }="" fclose(fp);="" fp="fopen(filename," "a");="" opens="" the="" file="" in="" append="" mode="" generaters(fp);="" fclose(fp);="" printf("reference="" string="" generated!\n");="" where="" 10="" is="" the="" number="" of="" frames.="" each="" element="" m[f]="" represents="" one="" frame="" and="" contains="" the="" number="" p="" of="" the="" page="" currently="" residing="" in="" the="" frame="" f.="" *="" the="" main="" distinguishing="" property="" of="" a="" reference="" string="" rs="" is="" the="" degree="" of="" locality.="" a="" reference="" string="" constructed="" as="" a="" sequence="" of="" random="" numbers="" distributed="" uniformly="" over="" the="" range="" [0="" :="" p="" -="" 1]="" has="" no="" locality.="" such="" a="" string="" represents="" a="" situation="" where="" too="" many="" processes="" are="" running="" concurrently="" and="" the="" lack="" of="" locality="" results="" in="" thrashing.="" most="" programs="" display="" a="" high="" degree="" of="" locality,="" which="" can="" be="" modeled="" as="" follows:="" consecutive="" pages="" are="" drawn="" from="" a="" small="" region="" within="" [0="" :="" p="" -="" 1],="" referred="" to="" as="" the="" current="" locus="" of="" reference,="" l.="" l="" is="" defined="" by="" a="" starting="" position,="" s,="" within="" [0="" :="" p="" -="" e]="" and="" size,="" e.="" in="" reality,="" l="" is="" not="" a="" contiguous="" region="" since="" pages="" from="" at="" least="" three="" regions="" (code,="" data,="" and="" stack)="" are="" being="" accessed.="" for="" studying="" page-replacement="" algorithms,="" however,="" only="" the="" size="" of="" l="" is="" of="" interest="" and="" thus="" a="" contiguous="" locus="" of="" reference="" is="" adequate.="" the="" locus="" l="" gradually="" shifts="" to="" the="" right,="" which="" emulates="" sequential="" execution="" of="" the="" program.="" the="" rate="" of="" the="" motion="" is="" governed="" by="" a="" constant,="" m,="" which="" determines="" how="" many="" pages="" are="" chosen="" from="" l="" before="" l="" is="" shifted="" to="" the="" right.="" at="" random="" time="" points,="" l="" moves="" to="" a="" new="" location,="" s,="" within="" [0="" :="" p="" -="" e],="" chosen="" at="" random.="" the="" change="" represents="" the="" occasional="" transition="" of="" the="" program="" to="" a="" new="" area,="" resulting="" from="" a="" function="" call="" or="" a="" branch="" instruction.="" */="" }="" fifo="" algorithm="" #include=""> main(){ int reference_string[10],i=0; printf("Enter Reference String:\nEnter -1 to exit:\nEnter No:"); scanf("%d",&reference_string[i]); while(reference_string[i]!=-1){ i++; printf("Enter No:"); scanf("%d",&reference_string[i]); } int n,j=0,k,a[n],pf=0,ph=0,flag=0; printf("Enter no of frames:"); scanf("%d",&n); printf("\t\t\n\n----------------\n\t\t reference string "); i = 0; while(reference_string[i] != -1){ printf("%d ",reference_string[i]); i++; } printf("\n\n"); for(i=0;i
Jul 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here