Class Job
java.lang.Object
|
+----Job
- class Job
- extends Object
A Job represents one customer of services. It records the job's current
state as well as statistics about its lifetime. It generally spends its
lifetime moving form Server to Server.
One Job is created from each line of the input trace file.
The resources required by a Job are characterized by an amount `cpuNeeded'
of CPU time (all times are in milliseconds) and a number `ioNeeded' of I/O
operations, each representing one disk transfer of Sim.BLOCKSIZE bytes of
data. The CPU time is assumed to be distributed as evenly as possible into
ioNeeded "bursts" of cpu time, each followed by an I/O operation (unless the
job does no I/O at all).
Note the terminology: A "burst" is the amount of computing a Job wants
to do before choosing to do I/O. Depending on the CPU scheduing algorithm
in force, these bursts may be divided into "quanta" (plural of "quantum").
-
arrivalTime
- Arrival time in ms from start of simulation
-
BLOCKED
- Job needs to do an I/O operation next
-
burst
- size of current burst
-
burstRemaining
- amount in current burst (until next I/O op) remaining
-
burstStart
- time when current burst started (job "arrived" at the cpu queue)
-
cpuNeeded
- Total CPU time (ms) required by this job
-
cpuRemaining
- total amount of CPU time (in ms) left to consume
-
DONE
- Job has completed
-
ioNeeded
- Total number of I/O operations required by this job
-
ioRemaining
- number of I/O operations left to do
-
lastSerial
- Counter used for assigning serial numbers to Jobs (for debugging
output).
-
lastStart
- time when this Jobs last started using the CPU
-
name
- Name of this job (for debugging)
-
next
- Link for linking into queues
-
rand
- random number generator used by newBurst
-
READY
- Job is ready to run
-
serial
- Serial number of this job (for debugging)
-
trace
- Trace of significant events in this job's lifetime
(only if Sim.traceFlag)
-
Job(BufferedReader)
- Create a Job from a line of the trace file.
-
doIO()
- Called when this Job does an I/O operation
-
finish()
- This job is finished.
-
newBurst()
- Recaculate the amount of CPU to be used by this job before the next
I/O operation: the amount of cpu time remaining divided by the
number of I/O operations remaining, rounded up.
-
nextBurst()
- Return the amount of CPU time remaining for this job until
it next does I/O, or completes.
-
start()
- Called when this Job is started running on the CPU
-
state()
- What is the current state of this Job?
-
stop()
- Called when this Job is removed from the CPU
-
toString()
- For debugging, information about this device.
name
private String name
- Name of this job (for debugging)
serial
private int serial
- Serial number of this job (for debugging)
trace
private Vector trace
- Trace of significant events in this job's lifetime
(only if Sim.traceFlag)
next
Job next
- Link for linking into queues
arrivalTime
int arrivalTime
- Arrival time in ms from start of simulation
cpuNeeded
private int cpuNeeded
- Total CPU time (ms) required by this job
ioNeeded
private int ioNeeded
- Total number of I/O operations required by this job
ioRemaining
private int ioRemaining
- number of I/O operations left to do
cpuRemaining
private int cpuRemaining
- total amount of CPU time (in ms) left to consume
burst
public int burst
- size of current burst
burstRemaining
private int burstRemaining
- amount in current burst (until next I/O op) remaining
burstStart
public int burstStart
- time when current burst started (job "arrived" at the cpu queue)
lastStart
private int lastStart
- time when this Jobs last started using the CPU
rand
private Random rand
- random number generator used by newBurst
lastSerial
private static int lastSerial
- Counter used for assigning serial numbers to Jobs (for debugging
output).
DONE
public static final int DONE
- Job has completed
BLOCKED
public static final int BLOCKED
- Job needs to do an I/O operation next
READY
public static final int READY
- Job is ready to run
Job
public Job(BufferedReader traceFile) throws EOFException
- Create a Job from a line of the trace file.
- Parameters:
- traceFile - the file to read from.
toString
public String toString()
- For debugging, information about this device.
- Returns:
- information about the device: If verbosity > 2,
name:jobnumber[arrival-time; cpu; io]
where cpu = total/remaining/burst-remaining
and io = total/remaining
otherwise, just the name and serial number (like a prisoner of war).
- Overrides:
- toString in class Object
state
public int state()
- What is the current state of this Job?
- Returns:
- READY, BLOCKED, or DONE
start
public void start()
- Called when this Job is started running on the CPU
stop
public void stop()
- Called when this Job is removed from the CPU
nextBurst
public int nextBurst()
- Return the amount of CPU time remaining for this job until
it next does I/O, or completes.
- Returns:
- the remaining time (in milliseconds)
doIO
public void doIO()
- Called when this Job does an I/O operation
finish
public JobStats finish()
- This job is finished. Return some summary statistics.
- Returns:
- summary statistics.
newBurst
private void newBurst()
- Recaculate the amount of CPU to be used by this job before the next
I/O operation: the amount of cpu time remaining divided by the
number of I/O operations remaining, rounded up. This spreads the
cpu time as even as possible in to bursts, each preceding one I/O.
The case ioRemaining==0 only arises if the job does no I/O at all.
To give a little variety, we occasionally create an unusual burst
that is x*b in length, where b is the "normal" burst length (as
just described) and x is a random number uniformly distributed between
0 and 2.
In any case, the result is limited by the amount of CPU time remaining.