|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Device
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.
JobArrival
,
Sim#mainLoop()
Field Summary | |
private Job |
currentJob
The current job, if running. |
private java.lang.String |
name
The name of the device (for diagnostic output) |
private int |
nextInterruptTime
When will it next interrupt? (MAX_VALUE if not running) |
private boolean |
running
Is the device currently running? |
private int |
startedAt
When did it last start running? (meaningless if not running) |
private int |
totalTime
What is the total amount of time it has been running? |
private java.util.Vector |
trace
Trace of significant events in this device's lifetime (only if Sim.traceFlag) |
Constructor Summary | |
(package private) |
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 |
|
Field Detail |
private java.lang.String name
private java.util.Vector trace
private boolean running
private Job currentJob
private int nextInterruptTime
private int startedAt
private int totalTime
Constructor Detail |
Device(java.lang.String name)
name
- the name of the device.Method Detail |
public Job current()
public java.lang.String toString()
public void start(Job j, int amt)
j
- the job to runamt
- for generic devices, the amount of time to run the job, in
milliseconds. Specific devices may interpret the argument
differently.public Job stop()
public final int nextInterrupt()
public boolean isBusy()
public void printStats()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |