Class Device

java.lang.Object
  |
  +--Device
Direct Known Subclasses:
CPU, JobArrival

public class Device
extends java.lang.Object

A Device can be running or stopped. Once started, it will "interrupt" at some time in the future. Since this is a simulation, interrupts are a bit funny: Each device indicates the simulation time when the interrupt will occur and Sim.mainLoop() polls the devices, see which one is next to interrupt. It then advances its current time to the time of the interrupt, stops the device, and does what the "interrupt handler" for the device would do. In the current version of the simulation, the disk, clock, and cpu devices are all instances of Device. Job arrivals are represented by a pseudo-device JobArrival, which extends Device.

See Also:
JobArrival, Sim.mainLoop(String, String, int)

Constructor Summary
Device(java.lang.String name)
          Initialize the Device.
 
Method Summary
 Job current()
          Get the current job.
 boolean isBusy()
          Is the device currently runing?
 int nextInterrupt()
          Retrieve the time when the next interrupt will occur.
 void printStats()
          Print information about this device
 void start(Job j, int amt)
          Start a device running, servicing a job.
 Job stop()
          Stop the device.
 java.lang.String toString()
          For debugging, information about this device.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Device

public Device(java.lang.String name)
Initialize the Device.
Parameters:
name - the name of the device.
Method Detail

current

public Job current()
Get the current job.
Returns:
the current job (null if device is idle)

toString

public java.lang.String toString()
For debugging, information about this device.
Overrides:
toString in class java.lang.Object
Returns:
the name of this device.

start

public void start(Job j,
                  int amt)
Start a device running, servicing a job.
Parameters:
j - the job to run
amt - for generic devices, the amount of time to run the job, in milliseconds. Specific devices may interpret the argument differently.

stop

public Job stop()
Stop the device.
Returns:
the job that was being serviced by the device.

nextInterrupt

public final int nextInterrupt()
Retrieve the time when the next interrupt will occur.
Returns:
the time of the completion interrupt (-1 if not running).

isBusy

public boolean isBusy()
Is the device currently runing?
Returns:
true if the device is running .

printStats

public void printStats()
Print information about this device