|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.man.cs.rainbow.simulator.Scheduler | +--uk.ac.man.cs.rainbow.simulator.StateEnumerator
Simulation state enumerator. State enumerators are a kind of scheduler that permits precisely controlled execution of a simulation, with an external environment specifiying exactly what action should be performed every time there is a choice. They support state saving and reloading, and can be asked to produce a characterisation of the state of the whole simulation.
RainbowThread
,
Rainbow Implementors Guide, Serialized FormInner Class Summary | |
static class |
StateEnumerator.ChanWatch
For debugging channel activity. |
static class |
StateEnumerator.NDData
So the state of the scheduler can be characterised. |
protected static class |
StateEnumerator.SavedEnumeratorState
|
static class |
StateEnumerator.ThreadWatch
For debugging thread activity. |
Inner classes inherited from class uk.ac.man.cs.rainbow.simulator.Scheduler |
Scheduler.ExternalExecutionServer, Scheduler.LabellingAdapter, Scheduler.LabellingListener, Scheduler.ThreadingAdapter, Scheduler.ThreadingListener |
Field Summary | |
static String |
DEBUG_COMPILATION_PROPERTY
The name of a property to set to true to enable compilation debugging. |
Constructor Summary | |
StateEnumerator()
Create a new state enumerator. |
|
StateEnumerator(File rainbowSourceFile)
Create a new state enumerator with the compiled version of the given file installed. |
Method Summary | |
void |
addCodeThread(RASMCode codeBlock)
Add a new top-level code thread. |
void |
advanceTime()
Advances time one step. |
protected void |
asap(RainbowThread thread)
Run thread as soon as possible in the current direction. |
void |
characterise(Data[] vec)
Put a characterisation of the state into the given vector. |
static boolean |
compareCharacterisations(Data[] characterisation1,
Data[] characterisation2)
Compare two characterisations. |
int |
countTransitions()
Count the transitions out of the current state. |
protected boolean |
delay(RainbowThread thread,
int delay)
Delay thread for a bit. |
boolean |
executeTransition(int transitionIndex)
Execute a transition. |
int |
getCharacterisationLength()
How long should a characterisation vector be? For any particular scheduler run, this is fixed, though the value is only determined after initialisation. |
long |
getTime()
What is the current time? |
void |
initialise()
Initialise the scheduler. |
boolean |
isInitialised()
Has this scheduler been initialised yet? |
boolean |
isNondeterministic()
Is the scheduler at a nondeterministic choice point? |
void |
restoreState(SavedState saved)
Reload a saved state. |
protected void |
reverse(RainbowThread thread)
Run thread as soon as possible in the opposite direction. |
ReclaimableSavedState |
saveState()
Save the state for later reloading. |
String |
toString()
What is going on? This is very useful for debugging! |
Methods inherited from class uk.ac.man.cs.rainbow.simulator.Scheduler |
addLabellingListener, addThreadingListener, readKeyedRegister, readKeyedRegister, removeLabellingListener, removeThreadingListener, setExternalExecutionServer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String DEBUG_COMPILATION_PROPERTY
StateEnumerator(File)
,
Boolean.getBoolean(String)
Constructor Detail |
public StateEnumerator()
public StateEnumerator(File rainbowSourceFile) throws RainbowException, IOException
rainbowSourceFile
- The file to load the Rainbow source text from.RainbowException
- If something goes wrong during the compilation and linking
stages.IOException
- If something goes wrong when reading a source file.RASMCode
,
Compiler
Method Detail |
public final ReclaimableSavedState saveState()
restoreState(SavedState)
public final void restoreState(SavedState saved) throws RainbowException
saved
- The saved state to reload.RainbowException
- If the state was saved by a different scheduler to the one it
is being reloaded into.ReclaimableSavedState.StateReloadException
- If a saved state that was moved to disk proves impossible to
reload for some reason.saveState()
public int getCharacterisationLength()
java.lang.NullPointerException
- If called before the scheduler is initialised.characterise(Data[])
public void characterise(Data[] vec)
vec
- The vector to write the characterisation into. The size of
this vector is fixed for any simulation run to allow more
efficient memory handling.java.lang.NullPointerException
- If called before the scheduler is initialised.java.lang.ArrayIndexOutOfBoundsException
- If the given vector is shorter than the required length.getCharacterisationLength()
,
RainbowThread.characterise()
public static boolean compareCharacterisations(Data[] characterisation1, Data[] characterisation2)
characterisation1
- The first characterisation vector to examine.characterisation2
- The second characterisation vector to examine.public void addCodeThread(RASMCode codeBlock)
addCodeThread
in class Scheduler
codeBlock
- The block of code specifying the code to run. The entry point
is the first instruction in the block of code.RainbowError
- If the scheduler has been initialised.public void initialise() throws RainbowException
initialise
in class Scheduler
RainbowException
- If something goes wrong during initialisation.executeTransition(int)
public int countTransitions()
executeTransition(int)
public boolean executeTransition(int transitionIndex) throws RainbowException
transitionIndex
- Which of the possible transitions to execute.RainbowError
- If the simulation is not initialised, or if the transition
index is not in the range 0 to
countTransitions()
.RainbowException
- If something goes wrong during the execution of the
transition.initialise()
,
countTransitions()
public void advanceTime()
getTime()
public final boolean isInitialised()
initialise()
call has
yet been performed.public final boolean isNondeterministic()
executeTransition()
will be a performing a choice at a
nondeterministic choice point or not.protected void asap(RainbowThread thread)
asap
in class Scheduler
thread
- The thread to schedule.protected void reverse(RainbowThread thread)
reverse
in class Scheduler
thread
- The thread to schedule.protected boolean delay(RainbowThread thread, int delay)
delay
in class Scheduler
thread
- The thread to delay.delay
- How long to delay for.public long getTime()
getTime
in class Scheduler
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |