Class Job

java.lang.Object
  |
  +--Job

class Job
extends java.lang.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").


Field Summary
(package private)  int arrivalTime
          Arrival time in ms from start of simulation
static int BLOCKED
          Job needs to do an I/O operation next
 int burst
          size of current burst
private  int burstRemaining
          amount in current burst (until next I/O op) remaining
 int burstStart
          time when current burst started (job "arrived" at the cpu queue)
private  int cpuNeeded
          Total CPU time (ms) required by this job
private  int cpuRemaining
          total amount of CPU time (in ms) left to consume
static int DONE
          Job has completed
private  int ioNeeded
          Total number of I/O operations required by this job
private  int ioRemaining
          number of I/O operations left to do
private static int lastSerial
          Counter used for assigning serial numbers to Jobs (for debugging output).
private  int lastStart
          time when this Jobs last started using the CPU
private  java.lang.String name
          Name of this job (for debugging)
(package private)  Job next
          Link for linking into queues
private  java.util.Random rand
          random number generator used by newBurst
static int READY
          Job is ready to run
private  int serial
          Serial number of this job (for debugging)
private  java.util.Vector trace
          Trace of significant events in this job's lifetime (only if Sim.traceFlag)
 
Constructor Summary
Job(java.io.BufferedReader traceFile)
          Create a Job from a line of the trace file.
 
Method Summary
 void doIO()
          Called when this Job does an I/O operation
 JobStats finish()
          This job is finished.
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.
 int nextBurst()
          Return the amount of CPU time remaining for this job until it next does I/O, or completes.
 void start()
          Called when this Job is started running on the CPU
 int state()
          What is the current state of this Job?
 void stop()
          Called when this Job is removed from the CPU
 java.lang.String toString()
          For debugging, information about this device.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

name

private java.lang.String name
Name of this job (for debugging)

serial

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

trace

private java.util.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 java.util.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
Constructor Detail

Job

public Job(java.io.BufferedReader traceFile)
    throws java.io.EOFException
Create a Job from a line of the trace file.
Parameters:
traceFile - the file to read from.
Method Detail

toString

public java.lang.String toString()
For debugging, information about this device.
Overrides:
toString in class java.lang.Object
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).

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.