CS 537
Programming Assignment 3
Frequently Asked Questions

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

A:
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.

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

or

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

A:
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.


Q3:
What parts of the program should I be changing?

A:
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.

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

A:
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.

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

[See also Q2]

A:
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 ***********");
to
    db("********** Simulation completed at " + currentTime + " ***********");