Class Device
java.lang.Object
   |
   +----Device
  -  class Device
  -  extends 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, mainLoop
   
  -   currentJob currentJob
-  The current job, if running.
  
-   name name
-  The name of the device (for diagnostic output)
  
-   nextInterruptTime nextInterruptTime
-  When will it next interrupt? (MAX_VALUE if not running)
  
-   running running
-  Is the device currently running?
  
-   startedAt startedAt
-  When did it last start running?  (meaningless if not running)
  
-   totalTime totalTime
-  What is the total amount of time it has been running?
  
-   trace trace
-  Trace of significant events in this device's lifetime
 (only if Sim.traceFlag)
   
  -   Device(String) Device(String)
-  Initialize the Device.
   
  -   current() current()
-  Get the current job.
  
-   isBusy() isBusy()
-  Is the device currently runing?
 
  
-   nextInterrupt() nextInterrupt()
-  Retrieve the time when the next interrupt will occur.
  
-   printStats() printStats()
-  Print information about this device
  
-   start(Job, int) start(Job, int)
-  Start a device running, servicing a job.
  
-   stop() stop()
-  Stop the device.
  
-   toString() toString()
-  For debugging, information about this device.
   
 name
name
 private String name
  -  The name of the device (for diagnostic output)
 
 trace
trace
 private Vector trace
  -  Trace of significant events in this device's lifetime
 (only if Sim.traceFlag)
 
 running
running
 private boolean running
  -  Is the device currently running?
 
 currentJob
currentJob
 private Job currentJob
  -  The current job, if running.
 
 nextInterruptTime
nextInterruptTime
 private int nextInterruptTime
  -  When will it next interrupt? (MAX_VALUE if not running)
 
 startedAt
startedAt
 private int startedAt
  -  When did it last start running?  (meaningless if not running)
 
 totalTime
totalTime
 private int totalTime
  -  What is the total amount of time it has been running?
 
   
 Device
Device
 Device(String name)
  -  Initialize the Device.
   
- 
    -  Parameters:
    
-  name - the name of the device.
  
 
   
 current
current
 public Job current()
  -  Get the current job.
   
- 
    -  Returns:
    
-  the current job (null if device is idle)
  
 
 toString
toString
 public String toString()
  -  For debugging, information about this device.
   
- 
    -  Returns:
    
-  the name of this device.
    
-  Overrides:
    
-  toString in class Object
  
 
 start
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
stop
 public Job stop()
  -  Stop the device.
   
- 
    -  Returns:
    
-  the job that was being serviced by the device.
  
 
 nextInterrupt
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
isBusy
 public boolean isBusy()
  -  Is the device currently runing?
   
- 
    -  Returns:
    
-  true if the device is running .
  
 
 printStats
printStats
 public void printStats()
  -  Print information about this device