1- package engine .atomicity .conflictserializability .thb ;
1+ package engine .atomicity .conflictserializability .aerodrome ;
22
33import java .util .ArrayList ;
44import java .util .HashMap ;
1111import event .Variable ;
1212import util .vectorclock .VectorClockOpt ;
1313
14- public class THBState extends State {
14+ public class AerodromeState extends State {
1515
1616 // Internal data
1717 public HashMap <Thread , Integer > threadToIndex ;
@@ -28,25 +28,25 @@ public class THBState extends State {
2828 public HashMap <Variable , VectorClockOpt > clockReadVariable ; // mathcal{R}
2929 public HashMap <Variable , VectorClockOpt > clockReadVariableCheck ; // mathcal{chR}
3030
31- public HashMap <Lock , Thread > lastThreadToRelease ;
32- public HashMap <Variable , Thread > lastThreadToWrite ;
31+ public HashMap <Lock , Thread > lastThreadToRelease ; // lastRelThr
32+ public HashMap <Variable , Thread > lastThreadToWrite ; // lastWThr
3333
3434 private HashMap <Thread , Integer > threadToNestingDepth ;
3535
3636 //Optimization data structures
37- public HashMap <Thread , HashSet <Variable >> updateSetThread_write ;
38- public HashMap <Thread , HashSet <Variable >> updateSetThread_read ;
37+ public HashMap <Thread , HashSet <Variable >> updateSetThread_write ; // UpdateSet^w
38+ public HashMap <Thread , HashSet <Variable >> updateSetThread_read ; // UpdateSet^r
39+ public HashSet <Variable > staleWrites ; // Stale^w
40+ public HashMap <Variable , HashSet <Thread >> staleReads ; // Stale^r
3941
40- public HashMap <Variable , HashSet <Thread >> staleReads ;
41- public HashSet <Variable > staleWrites ;
42-
42+ // Other data-structures to track if parent transaction is alive
4343 public HashMap <Thread , HashSet <Thread >> threadsForkedInActiveTransaction ;
4444 public HashSet <Thread > parentTransactionIsAlive ;
4545
4646 //parameter flags
4747 public int verbosity ;
4848
49- public THBState (HashSet <Thread > tSet , int verbosity ) {
49+ public AerodromeState (HashSet <Thread > tSet , int verbosity ) {
5050 this .verbosity = verbosity ;
5151 initInternalData (tSet );
5252 initData (tSet );
@@ -58,7 +58,6 @@ private void initInternalData(HashSet<Thread> tSet) {
5858 Iterator <Thread > tIter = tSet .iterator ();
5959 while (tIter .hasNext ()) {
6060 Thread thread = tIter .next ();
61- //System.out.println("Adding thread to map " + thread.toString());
6261 this .threadToIndex .put (thread , (Integer )this .numThreads );
6362 this .numThreads ++;
6463 }
@@ -121,9 +120,6 @@ public void initData(HashSet<Thread> tSet) {
121120
122121 // Access methods
123122 private VectorClockOpt getVectorClockFrom1DArray (ArrayList <VectorClockOpt > arr , int index ) {
124- // if (index < 0 || index >= arr.size()) {
125- // throw new IllegalArgumentException("Illegal Out of Bound access");
126- // }
127123 return arr .get (index );
128124 }
129125
@@ -139,18 +135,15 @@ public VectorClockOpt getVectorClock(ArrayList<VectorClockOpt> arr, Thread t) {
139135 }
140136
141137 public VectorClockOpt getVectorClock (HashMap <Lock , VectorClockOpt > arr , Lock l ) {
142- // checkAndAddLock(l);
143138 return arr .get (l );
144139 }
145140
146141 public VectorClockOpt getVectorClock (HashMap <Variable , VectorClockOpt > arr , Variable v ) {
147- // checkAndAddVariable(v);
148142 return arr .get (v );
149143 }
150144
151145 public int checkAndAddLock (Lock l ){
152146 if (!lockToIndex .containsKey (l )){
153- //System.err.println("New lock found " + this.numLocks);
154147 lockToIndex .put (l , this .numLocks );
155148 this .numLocks ++;
156149 this .clockLock .put (l , new VectorClockOpt (this .numThreads ));
@@ -183,18 +176,6 @@ public void decrementNestingDepth(Thread t) {
183176 int cur_depth = threadToNestingDepth .get (t );
184177 threadToNestingDepth .put (t , cur_depth - 1 );
185178 }
186-
187- // public boolean checkAndGetClock(VectorClockOpt checkClock, VectorClockOpt fromClock, Thread target) {
188- // int tIndex = this.threadToIndex.get(target);
189- // boolean violationDetected = false;
190- // VectorClockOpt C_target_begin = getVectorClock(clockThreadBegin, target);
191- // if(C_target_begin.isLessThanOrEqual(checkClock, tIndex) && transactionIsActive(target)) {
192- // violationDetected = true;
193- // }
194- // VectorClockOpt C_target = getVectorClock(clockThread, target);
195- // C_target.updateWithMax(C_target, fromClock);
196- // return violationDetected;
197- // }
198179
199180 public boolean checkAndGetClock (VectorClockOpt checkClock , VectorClockOpt fromClock , Thread target ) {
200181 int tIndex = this .threadToIndex .get (target );
@@ -287,7 +268,7 @@ public void updateCheckClock(VectorClockOpt vc1, VectorClockOpt vc2, Thread t) {
287268 vc1 .updateMax2WithoutLocal (vc2 , tIndex );
288269 }
289270
290- // This assumes that local clocks are not increment for events inside a
271+ // This assumes that local clocks are not increment for events inside a transaction
291272 public boolean hasIncomingEdge (Thread t ) {
292273
293274 if (parentTransactionIsAlive .contains (t )) return true ;
0 commit comments