jmce - 1_02

jmce.sim
Class AbstractPeripheral

java.lang.Object
  extended by jmce.sim.AbstractHardware
      extended by jmce.sim.AbstractPeripheral
All Implemented Interfaces:
Hardware, Peripheral
Direct Known Subclasses:
AbstractDisk, AbstractDiskController, AbstractMemory, AbstractTape, BootLoader, CTC, Delay, Device, DiseqcMotor, Display, Display, I2cBus, I8237, JPorts, KeyboardMatrix, Leds, Loadable, Port, Ports, SAA5050, Screen, SIMH, Speaker, Speaker, SwingKeyboard, SysKit, Timer, Timer, Timer, Timer2, VIA6522, VIC6561

public abstract class AbstractPeripheral
extends AbstractHardware
implements Peripheral

Abstract implementation of Peripheral

To support idle loop detection and save cpu time the peripheral must call the method setIdle when a status operation is made and setLive when a read / write operation is made. So after 10 seconds of only status operation any subseguent call to setIdle release the cpu.

Version:
1.01
Author:
Mario Viara

Field Summary
protected  CPU cpu
           
 
Constructor Summary
AbstractPeripheral()
          Default constructor
AbstractPeripheral(java.lang.String name)
          Constructor with name
 
Method Summary
 int idle()
          If a CPU is registred call the idle method oterwise use the Thread.yield method to wait for few ms.
 void registerCPU(CPU cpu)
          Register a parent CPU for future reference.
protected  void setIdle()
          Set idle.
protected  void setLive()
          Set live.
 
Methods inherited from class jmce.sim.AbstractHardware
addHardware, createFrame, destroy, getHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareForName, getHardwareInstances, getHardwareTree, getName, getParent, init, initSwing, removeHardware, removeHardware, reset, setHardware, setHardware, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmce.sim.Hardware
addHardware, destroy, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareInstances, getHardwareTree, getName, getParent, init, initSwing, removeHardware, removeHardware, reset, setHardware, setHardware, setName
 

Field Detail

cpu

protected CPU cpu
Constructor Detail

AbstractPeripheral

public AbstractPeripheral(java.lang.String name)
Constructor with name


AbstractPeripheral

public AbstractPeripheral()
Default constructor

Method Detail

registerCPU

public void registerCPU(CPU cpu)
                 throws SIMException
Description copied from interface: Peripheral
Register a parent CPU for future reference.

Specified by:
registerCPU in interface Peripheral
Throws:
SIMException

idle

public int idle()
         throws SIMException
If a CPU is registred call the idle method oterwise use the Thread.yield method to wait for few ms.

Specified by:
idle in interface Peripheral
Returns:
the number of ms elapsed.
Throws:
SIMException

setIdle

protected final void setIdle()
                      throws SIMException
Set idle.

Called from sub class when the cpu make a status I/O operation. After 10 seconds of only status operation the method call automatically idle.

Throws:
SIMException
Since:
1.01
See Also:
idle(), setLive()

setLive

protected final void setLive()
Set live.

Called from sub class when the cpu make a read / write opearation.

Since:
1.01
See Also:
setIdle()

jmce - 1_02