Class ExecutionGraph
Contains the exploration and all the relations defined according to the Trust algorithm. For now this class implements the sequential consistency model. Which, in theory, could be extended to other models.
Some terminology to understand the code
- TO: Total order of events observed in this execution graph, in the order they were added
- PO: Program order. A union of reads from partial order and the total order of events per task
- RF: Reads from relation between reads and writes
- CO: A coherency order between writes
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceGeneric visitor interface for the execution graph nodes.static classTopological sorter for the execution graph. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidacquireLock(Integer location, Long taskId) voidaddBlockingLabel(Long taskId) Adds a blocking label to the execution graph.Adds an event to the execution graph.voidblockTaskForLock(Event event) voidchangeReadsFrom(ExecutionGraphNode read, ExecutionGraphNode write) Updates the reads from relation between the given read and write events.booleanvoidbooleanbooleanvoidclear()Clears the execution graph.clone()Creates a clone of the execution graph.booleanReturns true if the execution graph contains the event with the given key.booleanReturns all the writes in the execution graph.Returns the alternative reads to the given write event.Returns the potential alternative writes to the given lock read.Returns the alternative writes (in reverse CO order) to the given read event.Returns the coherency placings of the given write event under sequential consistency.Returns the last write event to the given location.getEventNode(Event.Key key) Returns the event node with the given key.Returns the potential alternative reads to the given write event.static List<SchedulingChoiceWrapper> getTaskSchedule(List<ExecutionGraphNode> taskEvents) Generate a task Schedule from a given sorted list of event nodes.protected intgetTOIndex(Event.Key key) Returns the index of the given key in the TO order.protected intgetTOIndex(ExecutionGraphNode node) Returns the index of the given node in the TO order.Returns the list of task identifiers in the execution graph where a new event can be added.Returns the writes to the given location.booleanhasEventNode(Event.Key key) Returns true if the execution graph has an event node with the given key.booleanisEmpty()Returns true if the graph contains only the initial event.booleanbooleanisTaskBlocked(Long taskId) Checks if the task with the given ID is blocked.iterator()Returns an iterator walking through the nodes in a topological sort order.voidprintCO()voidvoidRecomputes the vector clocks of all nodes in the execution graph.voidrestrict(ExecutionGraphNode restrictingNode) voidrestrictBySet(Set<Event.Key> set) revisitView(ExecutionGraphNode write, ExecutionGraphNode read) Constructs a backward revisit view of the ExecutionGraph.voidsetReadsFrom(ExecutionGraphNode read, ExecutionGraphNode write) Sets the reads from relation between the given read and write events.voidswapCoherency(ExecutionGraphNode write1, ExecutionGraphNode write2) Resets the coherency order between the given write events.voidtrackCoherency(ExecutionGraphNode write) Tracks the coherency order between the given write event and the previous write event to the same location.voidTracks the thread starts in the execution graph as a total ordervoidtrackThreadJoinCompletion(ExecutionGraphNode eventNode) voidTracks thread join events in the execution graph.voidvoidunblockAllTasksForLock(Integer location) voidunBlockTask(Long taskId) Unblocks the task with the given ID.Returns List of nodes while silently ignoring any errors with cycles *booleanwaitingForLock(Integer location, Long taskId)
-
Constructor Details
-
ExecutionGraph
public ExecutionGraph()Initializes a new execution graph.
-
-
Method Details
-
getTaskSchedule
Generate a task Schedule from a given sorted list of event nodes.Note that the generated Schedule involves tasks that are 1-indexed and The trust ExecutionGraph has tasks that are 0-indexed.
- Parameters:
taskEvents- A sorted list of event nodes- Returns:
- A list of SchedulingChoiceWrappers.
-
getUnblockedTasks
Returns the list of task identifiers in the execution graph where a new event can be added.- Returns:
- The list of task identifiers in the execution graph.
-
getTOIndex
Returns the index of the given node in the TO order.- Parameters:
node- The node to get the index of.- Returns:
- The index of the given node in the TO order (-1 if not found).
-
getTOIndex
Returns the index of the given key in the TO order.- Parameters:
key- The key to get the index of.- Returns:
- The index of the given key in the TO order (-1 if not found).
-
clone
Creates a clone of the execution graph. -
hasEventNode
Returns true if the execution graph has an event node with the given key.- Parameters:
key- The key of the event to check.- Returns:
- True if the execution graph has an event node with the given key.
-
getEventNode
Returns the event node with the given key.- Parameters:
key- The key of the event to get.- Returns:
- The event node with the given key.
- Throws:
NoSuchEventException- If the event with the given key is not found.
-
contains
Returns true if the execution graph contains the event with the given key.- Parameters:
key- The key of the event to check.- Returns:
- True if the execution graph contains the event with the given key.
-
addEvent
Adds an event to the execution graph.- Parameters:
event- The event to add.- Returns:
- The node representing the added event.
-
trackThreadJoins
Tracks thread join events in the execution graph. Adds a thread join edge from the last event of the joined task to the thread join event.- Parameters:
node- The node representing the thread join event.
-
trackThreadCreates
Tracks the thread starts in the execution graph as a total orderInternally, it uses a special location in the coherency Order to maintain the total order. Additionally, the relation is part of _porf_ and is reflected in the happens before.
- Parameters:
node- The node representing the thread start event.
-
trackThreadStarts
-
addBlockingLabel
Adds a blocking label to the execution graph.- Parameters:
taskId- The task ID to add the blocking label for.
-
isTaskBlocked
Checks if the task with the given ID is blocked.- Parameters:
taskId- The task ID to check.- Returns:
- True if the task with the given ID is blocked.
-
unBlockTask
Unblocks the task with the given ID.- Parameters:
taskId- The task ID to block.- Throws:
HaltCheckerException- If the task ID is invalid.
-
getCoMax
Returns the last write event to the given location.- Parameters:
location- The location to get the last write event for.- Returns:
- The last write event to the given location.
-
getAlternativeWrites
Returns the alternative writes (in reverse CO order) to the given read event.All writes that are not _porf_-before the given read. (Tied to Sequential consistency model) ecluding the CO max write.
- Parameters:
read- The read event node.- Returns:
- The alternative writes to the given read event.
-
getAlternativeLockReads
Returns the alternative reads to the given write event.All reads that are not _porf_-before the given write. Specifically looking for lock acquire reads. In the search, the concurrent writes do not include lock acquire exclusive writes.
- Parameters:
write- The write event node.- Returns:
- The alternative reads to the given write event.
-
getAlternativeLockWrites
Returns the potential alternative writes to the given lock read.Writes that other lock reads are reading from.
- Parameters:
read- The write event node.- Returns:
- The potential writes to the given read event.
-
getPotentialReads
Returns the potential alternative reads to the given write event.All reads that are not _porf_-before the given write.
- Parameters:
write- The write event node.- Returns:
- The potential reads to the given write event.
-
revisitView
Constructs a backward revisit view of the ExecutionGraph.- Parameters:
write- The write eventread- The read event that the write needs to backward revisit- Returns:
- The backward revisit view of the ExecutionGraph
-
getWrites
Returns the writes to the given location.- Parameters:
location- The location to get the writes for.- Returns:
- The writes to the given location.
-
getAllWrites
Returns all the writes in the execution graph.- Returns:
- All the writes in the execution graph.
-
swapCoherency
Resets the coherency order between the given write events. The later write is added just before the earlier write.Invalidates the total order of events in the graph. The concern of fixing the total order is passed to the calling function.
- Parameters:
write1- The first write event.write2- The second write event.
-
getCoherentPlacings
Returns the coherency placings of the given write event under sequential consistency.Writes that are not _porf_-before the given write event. (Tied to Sequential consistency model)
- Parameters:
write- The write event.- Returns:
- The coherency placings of the given write event.
-
changeReadsFrom
Updates the reads from relation between the given read and write events.Invalidates the total order and the vector clocks of events in the graph. The concern of fixing the total order and the vector clocks is passed to the calling function.
- Parameters:
read- The read event.write- The write event.
-
setReadsFrom
Sets the reads from relation between the given read and write events.Does not validate if there is an existing reads-from edge to the corresponding read
- Parameters:
read- The read event.write- The write event.
-
trackCoherency
Tracks the coherency order between the given write event and the previous write event to the same location.- Parameters:
write- The write event.
-
restrictBySet
-
recomputeVectorClocks
public void recomputeVectorClocks()Recomputes the vector clocks of all nodes in the execution graph. -
restrict
-
iterator
public List<ExecutionGraphNode> iterator() throws ExecutionGraph.TopologicalSorter.GraphCycleExceptionReturns an iterator walking through the nodes in a topological sort order. -
unsafeIterator
Returns List of nodes while silently ignoring any errors with cycles * -
checkExtensiveConsistency
public boolean checkExtensiveConsistency() -
checkReadsFromEdges
public boolean checkReadsFromEdges() -
checkConsistency
-
checkDanglingEdges
public void checkDanglingEdges() -
checkConsistencyAndTopologicallySort
-
isEmpty
public boolean isEmpty()Returns true if the graph contains only the initial event. -
clear
public void clear()Clears the execution graph. -
toJsonString
-
toJsonStringIgnoreLocation
-
printCO
public void printCO() -
equals
-
checkCoherencyEdges
public boolean checkCoherencyEdges() -
trackThreadJoinCompletion
-
blockTaskForLock
-
unblockAllTasksForLock
-
acquireLock
-
waitingForLock
-
printGraph
public void printGraph() -
isRfConsistent
public boolean isRfConsistent()
-