Class Job

java.lang.Object
  |
  +--Job

public 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
static int BLOCKED
          State value indicating that the Job needs to do an I/O operation next
 int burstStart
          Time when current burst started (job "arrived" at the cpu queue)
static int DONE
          State value indicating that the Job has completed
static int READY
          State value indicating that the Job is ready to run
 java.lang.Object schedulerInfo
          A place for the scheduler to store arbitrary info about this Job.
 
Constructor Summary
Job(java.io.BufferedReader traceFile)
          Creates a Job from a line of the trace file.
 
Method Summary
 int arrivalTime()
          Indicates when this Job first arrived in the system.
 int burstRemaining()
          Returns the amount of CPU time remaining for this job until it next blocks for I/O or completes.
 int burstUsed()
          Indicates the amount of CPU time has this job used since the start of the burst (not including overhead).
 int currentBurst()
          Indicates the total length of the current burst.
 void doIO()
          Called by the simulator when this Job does an I/O operation
 JobStats finish()
          This job is finished.
 void startJob()
          Called by the simulator when this Job is started running on the CPU
 int state()
          Indicates the current state of this Job.
 void stopJob()
          Called by the simulator when this Job is removed from the CPU
 java.lang.String toString()
          For debugging, information about this Job.
 void updateRemaining()
          Called when an accurate value of the remaining time for this job is needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DONE

public static final int DONE
State value indicating that the Job has completed

BLOCKED

public static final int BLOCKED
State value indicating that the Job needs to do an I/O operation next

READY

public static final int READY
State value indicating that the Job is ready to run

burstStart

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

schedulerInfo

public java.lang.Object schedulerInfo
A place for the scheduler to store arbitrary info about this Job.
Constructor Detail

Job

public Job(java.io.BufferedReader traceFile)
    throws java.io.EOFException
Creates 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 Job.
Overrides:
toString in class java.lang.Object
Returns:
information about the Job: If Sim.debugLevel() >= 2,
      job jobnumber[arrival-time; cpu; io]
      where cpu = total/remaining/burst-remaining
      and io = total/remaining
 
otherwise, just the serial number.

state

public int state()
Indicates the current state of this Job.
Returns:
READY, BLOCKED, or DONE

arrivalTime

public int arrivalTime()
Indicates when this Job first arrived in the system.
Returns:
arrival time (in ms since startup)

currentBurst

public int currentBurst()
Indicates the total length of the current burst. Note: This is "cheating". In a real system, this information is only available at the end of the burst.
Returns:
the length of the current burst.

burstRemaining

public int burstRemaining()
Returns the amount of CPU time remaining for this job until it next blocks for I/O or completes. Note: This is "cheating". In a real system, there would be no way to figure this out.
Returns:
the remaining time (in milliseconds)

burstUsed

public int burstUsed()
Indicates the amount of CPU time has this job used since the start of the burst (not including overhead). Note: Unlike currentBurst and burstRemaining, this is not cheating.
Returns:
the amount of CPU used since burst start.

startJob

public void startJob()
Called by the simulator when this Job is started running on the CPU

stopJob

public void stopJob()
Called by the simulator when this Job is removed from the CPU

updateRemaining

public void updateRemaining()
Called when an accurate value of the remaining time for this job is needed.

doIO

public void doIO()
Called by the simulator when this Job does an I/O operation

finish

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