Constant Rate

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?
You need to schedule each call with a high resolution timer nad just sleep/wait between calls.
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";

cin >> simulation;

}
I don't quite understand what you've done, you don't seem to dispatch any work in the loop.
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.
Last edited on
Ok.

If you're working with 1 second resolutions, then you don't have to be too careful I suppose.
Topic archived. No new replies allowed.