cz.vutbr.fit.racedetector
Class AtomRaceDetect

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

public class AtomRaceDetect
extends java.lang.Object
implements Detector

Implementation of the atomicity violation detection algorithm.

AtomRace - How it works

The algorithm is checking violation of predefined atomicities. Atomicity is a piece of the code which access some shared variable and should be executed atomically. Executed atomically means that no other thread will touch the shared vairable in the way which will leads to data inconsistency in between the start of the atomicity and the end of the atomicity.

Predefined atomicity is loaded from the file before the execution starts. The typical Atomicity has one begin and several ends. Both begin and ends are defined by access to the variable (program location is used for identification of access). Each access is also labeled by its type. Currently, there are three types of access (READ, WRITE and EXIT). In other words, Atomicity gives to each begin access a set of possible immediately following accesses to the same variable. EXIT type of access gives the algorithm information that the method is ending and it should stop checking atomicity for this variable. Atomicity is obtained from CFG of methods.

Algorithm starts to check for atomicity violation immediately before the begin access of the atomicity section and ends immediately after the end access. If two atomicities follow each other then during the access which represents end of the first and start of the second atomicity the algorithm checks for both atomicities. If during the checking some other thread (different from the one which enters the atomicity) is accessing the variable a suspected race is recorded. At the end of the atomicity it is checked whether consistency of the variable was not broken. The consistency is broken in the following scenarios:

Thread doing atomicity Other thread Problem description
read - write write The second write relies on a value from the preceding read that is overriden by other thread.
read - read write The write by other thread makes the two reads have different views of the variable.
write - write read Intermediate result that is assumed to be invisible to other threads is read by a remote access.
write - read write The read does not receive the local result it expects.
All these scenarios are unserializable. (More can be read for example in the article of SVD tool.) If some of this scenarios are detected the race warining is produced.

The core of this algorithm is implemented in the ARVariable class.

Author:
zdenek
See Also:
ARVariable

Field Summary
protected static AtomicityCollection violatedAtomicityCol
           
 
Constructor Summary
AtomRaceDetect()
           
 
Method Summary
 void afterAccessEvent(java.lang.String programLocation)
          Operations performed after access to the variable.
 void afterMethodEvent(java.lang.String programLocation)
          Called when method is being exited.
 void beforeAccessEvent(java.lang.String programLocation, java.lang.String varName, java.lang.Object instance, RaceDetector.Operation operation)
          Operations performed before access to the variable.
 void beforeMethodEvent(java.lang.String programLocation)
          Called when method is being entered.
 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)
          not implemented yet
 void monitorExitEvent(java.lang.String programLocation, int lock)
          not implemented yet
 void threadBeginEvent(java.lang.String programLocation)
          Construct a data structure to be used with the thread.
 void threadEndEvent()
          Remove a data structure being used with the thread.
 void threadJoinEvent(java.lang.String programLocation, java.lang.Thread target)
          not implemented yet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

violatedAtomicityCol

protected static AtomicityCollection violatedAtomicityCol
Constructor Detail

AtomRaceDetect

public AtomRaceDetect()
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.


beforeMethodEvent

public void beforeMethodEvent(java.lang.String programLocation)
Called when method is being entered.

Parameters:
programLocation -

afterMethodEvent

public void afterMethodEvent(java.lang.String programLocation)
Called when method is being exited.

Parameters:
programLocation -

monitorEnterEvent

public void monitorEnterEvent(java.lang.String programLocation,
                              int lock)
not implemented yet


monitorExitEvent

public void monitorExitEvent(java.lang.String programLocation,
                             int lock)
not implemented yet


threadBeginEvent

public void threadBeginEvent(java.lang.String programLocation)
Construct a data structure to be used with the thread.


threadEndEvent

public void threadEndEvent()
Remove a data structure being used with the thread.


threadJoinEvent

public void threadJoinEvent(java.lang.String programLocation,
                            java.lang.Thread target)
not implemented yet