uk.ac.man.cs.rainbow.deadlock
Class DeadlockChecker

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.deadlock.DeadlockChecker
Direct Known Subclasses:
PODeadlockChecker

public class DeadlockChecker
extends Object

Check a scheduling system for deadlock.

See Also:
StateEngine, StateEnumerator

Inner Class Summary
static interface DeadlockChecker.ExplorationObserver
          Allows the watching of the progress of a deadlock check.
 
Field Summary
static int DEADLOCK
          Indicates that a deadlock was found.
static int FINISHED
          Indicates that the system is free of deadlock.
static int WORKING
          Indicates that there is still more work to be done.
 
Constructor Summary
DeadlockChecker(StateEnumerator enumerator)
          Create a new deadlock-checker.
 
Method Summary
 void addExplorationObserver(DeadlockChecker.ExplorationObserver o)
          Register an object for notifications of exploration activity.
 StateEngine.ChannelEvent[][] canDeadlock()
          Search the entire state space for deadlock.
 StateEngine.ChannelEvent[][] canDeadlock(int steps)
          Search the entire state space for deadlock.
 StateEngine getStateEngine()
          Get the state engine.
protected  void notifyObservers(long minor, long major, int depth, int back)
          Send exploration notifications to all registered exploration observers.
 void removeExplorationObserver(DeadlockChecker.ExplorationObserver o)
          Unregister an object for notifications of exploration activity.
 int step()
          Perform a single deadlock step.
 int step(int count)
          Perform several steps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORKING

public static final int WORKING
Indicates that there is still more work to be done.
See Also:
step()

FINISHED

public static final int FINISHED
Indicates that the system is free of deadlock.
See Also:
step()

DEADLOCK

public static final int DEADLOCK
Indicates that a deadlock was found.
See Also:
step()
Constructor Detail

DeadlockChecker

public DeadlockChecker(StateEnumerator enumerator)
                throws RainbowException
Create a new deadlock-checker.
Parameters:
enumerator - The simulation that is to be deadlock-checked.
Throws:
RainbowException - If something goes wrong during initialisation of the scheduler.
Method Detail

step

public int step()
         throws RainbowException
Perform a single deadlock step.
Returns:
Whether the system has searched the whole state space, found a deadlock or still has more work to do.
Throws:
RainbowException - If something goes wrong during a step.
See Also:
DEADLOCK, FINISHED, WORKING

step

public int step(int count)
         throws RainbowException
Perform several steps.
Parameters:
count - The (maximum) number of steps to perform in this chunk of work.
Returns:
Whether the system has searched the whole state space, found a deadlock or still has more work to do.
Throws:
RainbowException - If something goes wrong during a step.
See Also:
step(), DEADLOCK, FINISHED, WORKING

canDeadlock

public StateEngine.ChannelEvent[][] canDeadlock(int steps)
                                         throws RainbowException
Search the entire state space for deadlock. This can take some time...
Parameters:
steps - The number of steps to be performed between calls to yield().
Returns:
An array of arrays of channel events (describing what happened) if a deadlock was found, and null if no deadlock was found.
Throws:
RainbowException - If something goes wrong during a step or if the thread is interrupted.
See Also:
step(), Thread.isInterrupted()

canDeadlock

public StateEngine.ChannelEvent[][] canDeadlock()
                                         throws RainbowException
Search the entire state space for deadlock. This can take some time...
Returns:
An array of arrays of channel events (describing what happened) if a deadlock was found, and null if no deadlock was found.
Throws:
RainbowException - If something goes wrong during a step or if the thread is interrupted.
See Also:
step()

getStateEngine

public StateEngine getStateEngine()
Get the state engine. Useful for reading off statistics...
Returns:
The state engine used by the deadlock-checker.

addExplorationObserver

public void addExplorationObserver(DeadlockChecker.ExplorationObserver o)
Register an object for notifications of exploration activity. An object may be registered several times, and if it is, it will receive that many notifications.

removeExplorationObserver

public void removeExplorationObserver(DeadlockChecker.ExplorationObserver o)
Unregister an object for notifications of exploration activity. If the object is registered several times, then only one registration will be removed. If the object is not registered, this method is equivalent to a null-operation.

notifyObservers

protected void notifyObservers(long minor,
                               long major,
                               int depth,
                               int back)
Send exploration notifications to all registered exploration observers.
Parameters:
minor - The number of minor transitions performed so far.
major - The number of major transitions performed so far. Note that a major transition is performed even when going to a state that has been seen before.
depth - The current stack (execution path) depth.
back - The number of states backtracked out of (the size of the store.) Note that when a transition is made to a state that has been seen before, this count is not increased.