I am creating a C project that simulates CPU Scheduler algorithms. The algorithims that are simulated are Round Robin, Shortest job first, Priority, and first come first serve. I have a simulation of 55 jobs that come in. I have randomly created numbers for the burst, quantum time, and priority of each job. I have created arrays that store the numbers and display each next to each job. I need to create arrays that will take in each job and its corresponding burst, priority, and quantum time numbers together. Right now each are stored in different arrays. I need the numbers to be in an array together so they will read out in a way that I can perform the necessary algorithms for each job. this is what I hav so far:#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip.h>
int main()
{
int burst[55], priority[55], quantum[55];
int i, j, k, l;
int job[55] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
cout<<"Job # Burst Priority Quantum"<<endl;
//Generate random numbers.
srand ( (unsigned int)time ( 0 ) ); //Sets random function seed to the value of the internal clock.
for ( i=0; i< 55; i++ )
burst = rand()%21;
for ( j=0; j< 55; j++ )
priority[j] = rand()%16;
for ( k=0; k< 55; k++ )
quantum[k] = rand()%16;
for ( l=0; l< 55; l++ )
cout<<job[l]<<setw(10)<<burst[l] <<setw(10)<<priority[l]<<setw(10)<<quantum[l]<<endl;
return 0;
}
Any help would be greatly appreciated!!
#include <stdlib.h>
#include <time.h>
#include <iomanip.h>
int main()
{
int burst[55], priority[55], quantum[55];
int i, j, k, l;
int job[55] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55};
cout<<"Job # Burst Priority Quantum"<<endl;
//Generate random numbers.
srand ( (unsigned int)time ( 0 ) ); //Sets random function seed to the value of the internal clock.
for ( i=0; i< 55; i++ )
burst = rand()%21;
for ( j=0; j< 55; j++ )
priority[j] = rand()%16;
for ( k=0; k< 55; k++ )
quantum[k] = rand()%16;
for ( l=0; l< 55; l++ )
cout<<job[l]<<setw(10)<<burst[l] <<setw(10)<<priority[l]<<setw(10)<<quantum[l]<<endl;
return 0;
}
Any help would be greatly appreciated!!