Package mars.simulator
Class SimulatorThread
java.lang.Object
java.lang.Thread
mars.simulator.SimulatorThread
- All Implemented Interfaces:
Runnable
Thread
subclass to perform MIPS simulation in the background. The thread can be interrupted using either
Simulator.pause()
or Simulator.terminate()
.- Author:
- Pete Sanderson, August 2005; Sean Clarke, April 2024
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionSimulatorThread
(Simulator simulator, int maxSteps, int[] breakPoints) Create a newSimulatorThread
without starting it. -
Method Summary
Modifier and TypeMethodDescriptionvoid
processJump
(int nextFetchPC) void
run()
Simulate the program given to this thread until a pause or finish condition is reached.void
Flag this thread to stop due to pausing.void
Flag this thread to stop due to termination.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
SimulatorThread
Create a newSimulatorThread
without starting it.- Parameters:
maxSteps
- Maximum number of instruction steps to simulate. Default of -1 means no maximum.breakPoints
- Array of breakpoints (instruction addresses) specified by user.
-
-
Method Details
-
stopForPause
public void stopForPause()Flag this thread to stop due to pausing. Once it has done so,SimulatorListener.simulatorPaused(SimulatorPauseEvent)
will be called for all registered listeners.This method may be called from any thread.
-
stopForTermination
public void stopForTermination()Flag this thread to stop due to termination. Once it has done so,SimulatorListener.simulatorFinished(SimulatorFinishEvent)
will be called for all registered listeners.This method may be called from any thread.
-
processJump
public void processJump(int nextFetchPC) -
run
public void run()Simulate the program given to this thread until a pause or finish condition is reached. Once the program starts,SimulatorListener.simulatorStarted(SimulatorStartEvent)
will be called for all registered listeners.
-