CS 537
Programming Assignment 3
Frequently Asked Questions

Last modified Sun Nov 23 08:49:20 CST 1997
In the Experiments section, you say
For each version of the simulator, for each input data file, for each quantum value, plot the
completion time,
average job elapsed time,
average job waiting time.
What do you mean by ``completion time''? How is that different from ``elapsed time''?

Elapsed time for one job is the total time it is in the system: the time it terminates minus the time it first arrived. ``Average elapsed time,'' as printed at the end of the simulation, is just the average of the elapsed times of all the jobs. In item (a), ``completion time'' means the time the whole simulation terminates. Since the simulation starts at time 0, the elapsed time for the whole simulation would be the same as its completion time.

I don't see any variation between algorithms on some of these parameters.


No matter how I vary the quantum size, XXX never changes.

That may be reasonable, or you may have a bug in your program. You can't tell whether your program is right just by the numbers it prints. You should look at part of the trace printed by using a fairly high number of ``-v'' options on the command line to see whether things seem to be happening in the same order.

Getting the program right is only one step in this assignment. A big part of it is to understand what's going on and how changes in the scheduling algorithm affect performance. See point 3 in this section. You are not limited to the list of parameters in part 1. You might want to look at some of the other statistics printed out by the program to help explain its behavior.

What parts of the program should I be changing?

Make a copy of RRScheduler.java and modify it to be a Lottery scheduler. Most of the work will be in rewriting the add, remove, and reschedule methods. You should only need to modify one line in Sim.java, the line that says ``cpuScheduler = new RRScheduler();.'' You will need to make some small changes to Job.java. You will most probably need to add a ticket field, and you may need to make a few other small changes. You shouldn't need to change anything else.

For solution 1, how can I tell when it is time to change a process' tickets?

The main loop of the scheduler calls add(j) under three different circumstances:
  1. When job j first arrives in the system.
  2. When job j becomes ready after doing some I/O.
  3. When job j is preempted from the CPU because you returned true from a call to add or reschedule.
You somehow need to distinguish among these cases. One way, is to add another field to the Job class (in addition to the ticket field, which you have to add anyhow) and set it to appropriate values in the Job constructor and in your add and reschedule methods. Another approach is to add something to the method Job.doIo.

The output says
    1:41:39.759: ********** Simulation completed ***********
How are we to interpret

[See also Q2]

That means 1 hour, 41 minutes, and 39.759 seconds (39 seconds and 759 milliseconds).

A shortcut to converting that to milliseconds is to change line 208 in Sim.java from

    db("********** Simulation completed ***********");
    db("********** Simulation completed at " + currentTime + " ***********");