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").


Variable Index

 o arrivalTime
Arrival time in ms from start of simulation
 o BLOCKED
Job needs to do an I/O operation next
 o burst
size of current burst
 o burstRemaining
amount in current burst (until next I/O op) remaining
 o burstStart
time when current burst started (job "arrived" at the cpu queue)
 o cpuNeeded
Total CPU time (ms) required by this job
 o cpuRemaining
total amount of CPU time (in ms) left to consume
 o DONE
Job has completed
 o ioNeeded
Total number of I/O operations required by this job
 o ioRemaining
number of I/O operations left to do
 o lastSerial
Counter used for assigning serial numbers to Jobs (for debugging output).
 o lastStart
time when this Jobs last started using the CPU
 o name
Name of this job (for debugging)
 o next
Link for linking into queues
 o rand
random number generator used by newBurst
 o READY
Job is ready to run
 o serial
Serial number of this job (for debugging)
 o trace
Trace of significant events in this job's lifetime (only if Sim.traceFlag)

Constructor Index

 o Job(BufferedReader)
Create a Job from a line of the trace file.

Method Index

 o doIO()
Called when this Job does an I/O operation
 o finish()
This job is finished.
 o 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.
 o nextBurst()
Return the amount of CPU time remaining for this job until it next does I/O, or completes.
 o start()
Called when this Job is started running on the CPU
 o state()
What is the current state of this Job?
 o stop()
Called when this Job is removed from the CPU
 o toString()
For debugging, information about this device.

Variables

 o name
 private String name
Name of this job (for debugging)

 o serial
 private int serial
Serial number of this job (for debugging)

 o trace
 private Vector trace
Trace of significant events in this job's lifetime (only if Sim.traceFlag)

 o next
 Job next
Link for linking into queues

 o arrivalTime
 int arrivalTime
Arrival time in ms from start of simulation

 o cpuNeeded
 private int cpuNeeded
Total CPU time (ms) required by this job

 o ioNeeded
 private int ioNeeded
Total number of I/O operations required by this job

 o ioRemaining
 private int ioRemaining
number of I/O operations left to do

 o cpuRemaining
 private int cpuRemaining
total amount of CPU time (in ms) left to consume

 o burst
 public int burst
size of current burst

 o burstRemaining
 private int burstRemaining
amount in current burst (until next I/O op) remaining

 o burstStart
 public int burstStart
time when current burst started (job "arrived" at the cpu queue)

 o lastStart
 private int lastStart
time when this Jobs last started using the CPU

 o rand
 private Random rand
random number generator used by newBurst

 o lastSerial
 private static int lastSerial
Counter used for assigning serial numbers to Jobs (for debugging output).

 o DONE
 public static final int DONE
Job has completed

 o BLOCKED
 public static final int BLOCKED
Job needs to do an I/O operation next

 o READY
 public static final int READY
Job is ready to run

Constructors

 o Job
 public Job(BufferedReader traceFile) throws EOFException
Create a Job from a line of the trace file.

Parameters:
traceFile - the file to read from.

Methods

 o 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
 o state
 public int state()
What is the current state of this Job?

Returns:
READY, BLOCKED, or DONE
 o start
 public void start()
Called when this Job is started running on the CPU

 o stop
 public void stop()
Called when this Job is removed from the CPU

 o 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)
 o doIO
 public void doIO()
Called when this Job does an I/O operation

 o finish
 public JobStats finish()
This job is finished. Return some summary statistics.

Returns:
summary statistics.
 o 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.