How do I create a C++ function which ensures that 20 jobs are sent every min in a queue program? Also,how do I use system clock to calculate time diff?
This is what I did but it doesn't exit @ the right place.
simulation refers to the length of simulation,num is a local variable initialised to 0. The idea is to have a queue simulation where every min, an avg of 20 jobs are processed.
while(num < simulation)
{
if (simulation >= MIN_SIM_TIME && simulation < MAX_SIM_TIME){
do{
jobID =getJobID();
wait(3);
simulation--;
}while(simulation%5 !=0);
if(simulation == 0)
{
count +=5;
cout << "Reached here" << count << endl;
}
num++;
}
else
{
cout << "Please provide a valid simulation period\n";
I have simulated a queue, the simulation period is represented by simulation. Whenever, the simulation time is reduced by 5, count is incremented by 5. Wat m trying 2 do is send 20 jobs every 60 secs. I realised the error was in wait(3), it should have been wait(1), hence I had a lag. The work dispatched is getting the jobID thru the jobID function until the value of simulation is a factor of 5.