cz.vutbr.fit.racedetector
Class EraserDetect

java.lang.Object
  extended by cz.vutbr.fit.racedetector.EraserDetect
All Implemented Interfaces:
Detector

public class EraserDetect
extends java.lang.Object
implements Detector

The implementation of the Eraser algorithm.

Eraser - how it works

Eraser is a lock set based race condition detection algorithm. It maintains for each shared variable a set of locks used with it. The set is build at the first access (at the second access if owner transfer is enabled). Then the algorithm do intersection of this set and the set of locks currently owned by the thread at the time of an access to the variable. If the lockset becomes empty the race warning is produced.

To suppress false alarms a finite automata representing the phase in which the variable is currently present is maintained. The race warning is produced only if the variable is in the RACE state of the automata. For more information refer the article about Eraser.

The core of this algorithm is implemented in the ERVariable class

Author:
zdenek
See Also:
ERVariable

Field Summary
protected static javolution.util.FastMap<javolution.util.Index,javolution.util.FastSet<javolution.util.Index>> joinSync
           
protected static javolution.util.FastMap<javolution.util.Index,java.lang.String> lockNames
           
protected static javolution.util.FastMap<javolution.util.Index,java.lang.String> threadNames
           
 
Constructor Summary
EraserDetect()
           
 
Method Summary
 void afterAccessEvent(java.lang.String programLocation)
          Operations performed after access to the variable.
 void beforeAccessEvent(java.lang.String programLocation, java.lang.String varName, java.lang.Object instance, RaceDetector.Operation operation)
          Operations performed before access to the variable.
 RDThread getNewThread()
          Returns a new thread object.
 RDVariable getNewVariable(java.lang.Object inst, java.lang.String str)
          Returns a new variable object.
 void monitorEnterEvent(java.lang.String programLocation, int lock)
          Add a lock to the set of held locks.
 void monitorExitEvent(java.lang.String programLocation, int lock)
          Remove a lock from the set of held locks.
 void threadBeginEvent(java.lang.String programLocation)
          Construct a data structure representing the thread.
 void threadEndEvent()
          Clean a data structure representing the thread.
 void threadJoinEvent(java.lang.String programLocation, java.lang.Thread target)
          Join synchronization implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockNames

protected static javolution.util.FastMap<javolution.util.Index,java.lang.String> lockNames

threadNames

protected static javolution.util.FastMap<javolution.util.Index,java.lang.String> threadNames

joinSync

protected static javolution.util.FastMap<javolution.util.Index,javolution.util.FastSet<javolution.util.Index>> joinSync
Constructor Detail

EraserDetect

public EraserDetect()
Method Detail

getNewVariable

public RDVariable getNewVariable(java.lang.Object inst,
                                 java.lang.String str)
Returns a new variable object.

Specified by:
getNewVariable in interface Detector
Parameters:
inst - Variable instance - according to ConTest.
str - Name of the variable - according to ConTest.
Returns:
variable object

getNewThread

public RDThread getNewThread()
Returns a new thread object.

Specified by:
getNewThread in interface Detector
Returns:
thread object

afterAccessEvent

public void afterAccessEvent(java.lang.String programLocation)
Operations performed after access to the variable.


beforeAccessEvent

public void beforeAccessEvent(java.lang.String programLocation,
                              java.lang.String varName,
                              java.lang.Object instance,
                              RaceDetector.Operation operation)
Operations performed before access to the variable.


monitorEnterEvent

public void monitorEnterEvent(java.lang.String programLocation,
                              int lock)
Add a lock to the set of held locks.


monitorExitEvent

public void monitorExitEvent(java.lang.String programLocation,
                             int lock)
Remove a lock from the set of held locks.


threadBeginEvent

public void threadBeginEvent(java.lang.String programLocation)
Construct a data structure representing the thread.


threadEndEvent

public void threadEndEvent()
Clean a data structure representing the thread.


threadJoinEvent

public void threadJoinEvent(java.lang.String programLocation,
                            java.lang.Thread target)
Join synchronization implementation. If successful join has been done - current thread is synchronized with target thread. Race between these two threads is no more possible.