|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.vutbr.fit.racedetector.AtomRaceDetect
public class AtomRaceDetect
Implementation of the atomicity violation detection algorithm.
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. |
The core of this algorithm is implemented in the ARVariable class.
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 |
---|
protected static AtomicityCollection violatedAtomicityCol
Constructor Detail |
---|
public AtomRaceDetect()
Method Detail |
---|
public RDVariable getNewVariable(java.lang.Object inst, java.lang.String str)
getNewVariable
in interface Detector
inst
- Variable instance - according to ConTest.str
- Name of the variable - according to ConTest.
public RDThread getNewThread()
getNewThread
in interface Detector
public void afterAccessEvent(java.lang.String programLocation)
public void beforeAccessEvent(java.lang.String programLocation, java.lang.String varName, java.lang.Object instance, RaceDetector.Operation operation)
public void beforeMethodEvent(java.lang.String programLocation)
programLocation
- public void afterMethodEvent(java.lang.String programLocation)
programLocation
- public void monitorEnterEvent(java.lang.String programLocation, int lock)
public void monitorExitEvent(java.lang.String programLocation, int lock)
public void threadBeginEvent(java.lang.String programLocation)
public void threadEndEvent()
public void threadJoinEvent(java.lang.String programLocation, java.lang.Thread target)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |