changes
authorbdemsky <bdemsky>
Fri, 25 Jun 2010 23:16:32 +0000 (23:16 +0000)
committerbdemsky <bdemsky>
Fri, 25 Jun 2010 23:16:32 +0000 (23:16 +0000)
Robust/TransSim/FileSim.java
Robust/TransSim/FlexScheduler.java

index 8baca55cd2d871c4bf89d46ff7b08923f5c9647f..68b19c76116edac79be97e2b8955b23b0b9a9378 100644 (file)
@@ -15,18 +15,21 @@ public class FileSim {
     System.out.println("Lazy Time="+ls.getTime());
     System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
     System.out.println("Stalltime="+ls.getStallTime()+" Backofftime="+ls.getBackoffTime());
     System.out.println("Lazy Time="+ls.getTime());
     System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
     System.out.println("Stalltime="+ls.getStallTime()+" Backofftime="+ls.getBackoffTime());
+    System.out.println("Abortedtime="+ls.getAbortedTime());
     ls=null;
 
     ls4.join();
     System.out.println("Fast Abort="+ls4.getTime());
     System.out.println("Aborts="+ls4.getAborts()+" Commit="+ls4.getCommits());
     System.out.println("Stalltime="+ls4.getStallTime()+" Backofftime="+ls4.getBackoffTime());
     ls=null;
 
     ls4.join();
     System.out.println("Fast Abort="+ls4.getTime());
     System.out.println("Aborts="+ls4.getAborts()+" Commit="+ls4.getCommits());
     System.out.println("Stalltime="+ls4.getStallTime()+" Backofftime="+ls4.getBackoffTime());
+    System.out.println("Abortedtime="+ls4.getAbortedTime());
     ls4=null;
 
     ls5.join();
     System.out.println("Attack Abort="+ls5.getTime());
     System.out.println("Aborts="+ls5.getAborts()+" Commit="+ls5.getCommits());
     System.out.println("Stalltime="+ls5.getStallTime()+" Backofftime="+ls5.getBackoffTime());
     ls4=null;
 
     ls5.join();
     System.out.println("Attack Abort="+ls5.getTime());
     System.out.println("Aborts="+ls5.getAborts()+" Commit="+ls5.getCommits());
     System.out.println("Stalltime="+ls5.getStallTime()+" Backofftime="+ls5.getBackoffTime());
+    System.out.println("Abortedtime="+ls5.getAbortedTime());
     ls5=null;
   }
 
     ls5=null;
   }
 
@@ -45,18 +48,21 @@ public class FileSim {
     System.out.println("Suicide Abort="+ls6.getTime());
     System.out.println("Aborts="+ls6.getAborts()+" Commit="+ls6.getCommits());
     System.out.println("Stalltime="+ls6.getStallTime()+" Backofftime="+ls6.getBackoffTime());
     System.out.println("Suicide Abort="+ls6.getTime());
     System.out.println("Aborts="+ls6.getAborts()+" Commit="+ls6.getCommits());
     System.out.println("Stalltime="+ls6.getStallTime()+" Backofftime="+ls6.getBackoffTime());
+    System.out.println("Abortedtime="+ls6.getAbortedTime());
     ls6=null;
 
     ls7.join();
     System.out.println("Timestamp Abort="+ls7.getTime());
     System.out.println("Aborts="+ls7.getAborts()+" Commit="+ls7.getCommits());
     System.out.println("Stalltime="+ls7.getStallTime()+" Backofftime="+ls7.getBackoffTime());
     ls6=null;
 
     ls7.join();
     System.out.println("Timestamp Abort="+ls7.getTime());
     System.out.println("Aborts="+ls7.getAborts()+" Commit="+ls7.getCommits());
     System.out.println("Stalltime="+ls7.getStallTime()+" Backofftime="+ls7.getBackoffTime());
+    System.out.println("Abortedtime="+ls7.getAbortedTime());
     ls7=null;
 
     ls8.join();
     System.out.println("Random Abort="+ls8.getTime());
     System.out.println("Aborts="+ls8.getAborts()+" Commit="+ls8.getCommits());
     System.out.println("Stalltime="+ls8.getStallTime()+" Backofftime="+ls8.getBackoffTime());
     ls7=null;
 
     ls8.join();
     System.out.println("Random Abort="+ls8.getTime());
     System.out.println("Aborts="+ls8.getAborts()+" Commit="+ls8.getCommits());
     System.out.println("Stalltime="+ls8.getStallTime()+" Backofftime="+ls8.getBackoffTime());
+    System.out.println("Abortedtime="+ls8.getAbortedTime());
     ls8=null;
   }
 
     ls8=null;
   }
 
@@ -76,18 +82,21 @@ public class FileSim {
     System.out.println("Karma Abort="+ls9.getTime());
     System.out.println("Aborts="+ls9.getAborts()+" Commit="+ls9.getCommits());
     System.out.println("Stalltime="+ls9.getStallTime()+" Backofftime="+ls9.getBackoffTime());
     System.out.println("Karma Abort="+ls9.getTime());
     System.out.println("Aborts="+ls9.getAborts()+" Commit="+ls9.getCommits());
     System.out.println("Stalltime="+ls9.getStallTime()+" Backofftime="+ls9.getBackoffTime());
+    System.out.println("Abortedtime="+ls9.getAbortedTime());
     ls9=null;
 
     ls10.join();
     System.out.println("Polite Abort="+ls10.getTime());
     System.out.println("Aborts="+ls10.getAborts()+" Commit="+ls10.getCommits());
     System.out.println("Stalltime="+ls10.getStallTime()+" Backofftime="+ls10.getBackoffTime());
     ls9=null;
 
     ls10.join();
     System.out.println("Polite Abort="+ls10.getTime());
     System.out.println("Aborts="+ls10.getAborts()+" Commit="+ls10.getCommits());
     System.out.println("Stalltime="+ls10.getStallTime()+" Backofftime="+ls10.getBackoffTime());
+    System.out.println("Abortedtime="+ls10.getAbortedTime());
     ls10=null;
 
     ls11.join();
     System.out.println("Eruption Abort="+ls11.getTime());
     System.out.println("Aborts="+ls11.getAborts()+" Commit="+ls11.getCommits());
     System.out.println("Stalltime="+ls11.getStallTime()+" Backofftime="+ls11.getBackoffTime());
     ls10=null;
 
     ls11.join();
     System.out.println("Eruption Abort="+ls11.getTime());
     System.out.println("Aborts="+ls11.getAborts()+" Commit="+ls11.getCommits());
     System.out.println("Stalltime="+ls11.getStallTime()+" Backofftime="+ls11.getBackoffTime());
+    System.out.println("Abortedtime="+ls11.getAbortedTime());
   }
 
   public static void p4(Executor e) throws Exception {
   }
 
   public static void p4(Executor e) throws Exception {
@@ -102,18 +111,21 @@ public class FileSim {
     System.out.println("ThreadPriority Abort="+ls12.getTime());
     System.out.println("Aborts="+ls12.getAborts()+" Commit="+ls12.getCommits());
     System.out.println("Stalltime="+ls12.getStallTime()+" Backofftime="+ls12.getBackoffTime());
     System.out.println("ThreadPriority Abort="+ls12.getTime());
     System.out.println("Aborts="+ls12.getAborts()+" Commit="+ls12.getCommits());
     System.out.println("Stalltime="+ls12.getStallTime()+" Backofftime="+ls12.getBackoffTime());
+    System.out.println("Abortedtime="+ls12.getAbortedTime());
     ls12=null;
 
     ls13.join();
     System.out.println("AttackTime Abort="+ls13.getTime());
     System.out.println("Aborts="+ls13.getAborts()+" Commit="+ls13.getCommits());
     System.out.println("Stalltime="+ls13.getStallTime()+" Backofftime="+ls13.getBackoffTime());
     ls12=null;
 
     ls13.join();
     System.out.println("AttackTime Abort="+ls13.getTime());
     System.out.println("Aborts="+ls13.getAborts()+" Commit="+ls13.getCommits());
     System.out.println("Stalltime="+ls13.getStallTime()+" Backofftime="+ls13.getBackoffTime());
+    System.out.println("Abortedtime="+ls13.getAbortedTime());
     ls13=null;
 
     ls14.join();
     System.out.println("AttackThread Abort="+ls14.getTime());
     System.out.println("Aborts="+ls14.getAborts()+" Commit="+ls14.getCommits());
     System.out.println("Stalltime="+ls14.getStallTime()+" Backofftime="+ls14.getBackoffTime());
     ls13=null;
 
     ls14.join();
     System.out.println("AttackThread Abort="+ls14.getTime());
     System.out.println("Aborts="+ls14.getAborts()+" Commit="+ls14.getCommits());
     System.out.println("Stalltime="+ls14.getStallTime()+" Backofftime="+ls14.getBackoffTime());
+    System.out.println("Abortedtime="+ls14.getAbortedTime());
     ls14=null;
   }
 
     ls14=null;
   }
 
index af8f40d820bc353e9da27722d266ab32ca177b68..8fc77ce98b4f4698dfd2cef8063f7e18c59ab0b8 100644 (file)
@@ -136,6 +136,24 @@ public class FlexScheduler extends Thread {
     return backoffcycles;
   }
 
     return backoffcycles;
   }
 
+  public long getAbortedTime() {
+    return abortedcycles;
+  }
+
+  //Computes wasted time
+  public void timewasted(int currthread, long currtime) {
+    Event e=currentevents[currthread];
+    Transaction trans=e.getTransaction();
+    int eIndex=e.getEvent();
+    long eTime=e.getTime();
+    long timeleft=eTime-currtime;
+    long totaltime=0;
+    for(int i=0;i<=eIndex;i++)
+      totaltime+=trans.getTime(i);
+    totaltime-=timeleft;//subtract off time to the next event
+    abortedcycles+=totaltime;
+  }
+
   //Aborts another thread...
   public void reschedule(int currthread, long currtime, long backofftime) {
     long time=currtime+backofftime;
   //Aborts another thread...
   public void reschedule(int currthread, long currtime, long backofftime) {
     long time=currtime+backofftime;
@@ -320,6 +338,7 @@ public class FlexScheduler extends Thread {
                serAbort.addPoint(currtime, threadid);
            } else if (policy==COMMIT||policy==LOCKCOMMIT) {
              //abort it immediately
                serAbort.addPoint(currtime, threadid);
            } else if (policy==COMMIT||policy==LOCKCOMMIT) {
              //abort it immediately
+             timewasted(threadid, currtime);
              reschedule(threadid, currtime, 0);
              abortcount++;
            }
              reschedule(threadid, currtime, 0);
              abortcount++;
            }
@@ -328,6 +347,7 @@ public class FlexScheduler extends Thread {
       }
     } else {
       abortcount++;
       }
     } else {
       abortcount++;
+      timewasted(ev.getThread(), currtime);
     }
     
     //add next transaction event...could be us if we aborted
     }
     
     //add next transaction event...could be us if we aborted
@@ -401,6 +421,7 @@ public class FlexScheduler extends Thread {
        //abort other transactions
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
        //abort other transactions
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
+         timewasted(thread, time);
          reschedule(thread, time, 0);
          abortcount++;
        }
          reschedule(thread, time, 0);
          abortcount++;
        }
@@ -428,6 +449,7 @@ public class FlexScheduler extends Thread {
          if (dback>0)
            backoff[thread]=dback;
          int atime=r.nextInt(backoff[thread]);
          if (dback>0)
            backoff[thread]=dback;
          int atime=r.nextInt(backoff[thread]);
+         timewasted(thread, time);
          reschedule(thread, time, atime);
          abortcount++;
        }
          reschedule(thread, time, atime);
          abortcount++;
        }
@@ -465,6 +487,7 @@ public class FlexScheduler extends Thread {
          if (dback>0)
            backoff[thread]=dback;
          int atime=r.nextInt(backoff[thread]);
          if (dback>0)
            backoff[thread]=dback;
          int atime=r.nextInt(backoff[thread]);
+         timewasted(thread, time);
          reschedule(thread, time, atime);
          abortcount++;
        }
          reschedule(thread, time, atime);
          abortcount++;
        }
@@ -476,6 +499,7 @@ public class FlexScheduler extends Thread {
        retrycount[ev.getThread()]=0;
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
        retrycount[ev.getThread()]=0;
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
+         timewasted(thread, time);
          reschedule(thread, time, 0);
          abortcount++;
        }
          reschedule(thread, time, 0);
          abortcount++;
        }
@@ -491,6 +515,7 @@ public class FlexScheduler extends Thread {
     } else if (policy==ATTACK) {
       for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
        Integer thread=(Integer)thit.next();
     } else if (policy==ATTACK) {
       for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
        Integer thread=(Integer)thit.next();
+       timewasted(thread, time);
        reschedule(thread, time, r.nextInt(backoff[thread.intValue()]));
        int dback=backoff[thread.intValue()]*2;
        if (dback>0)
        reschedule(thread, time, r.nextInt(backoff[thread.intValue()]));
        int dback=backoff[thread.intValue()]*2;
        if (dback>0)
@@ -499,6 +524,7 @@ public class FlexScheduler extends Thread {
       }
       return true;
     } else if (policy==SUICIDE) {
       }
       return true;
     } else if (policy==SUICIDE) {
+      timewasted(ev.getThread(), time);
       reschedule(ev.getThread(), time, r.nextInt(backoff[ev.getThread()]));
       int dback=backoff[ev.getThread()]*2;
       if (dback>0)
       reschedule(ev.getThread(), time, r.nextInt(backoff[ev.getThread()]));
       int dback=backoff[ev.getThread()]*2;
       if (dback>0)
@@ -518,6 +544,7 @@ public class FlexScheduler extends Thread {
       }
       if (opponenttime>ev.getTransaction().getTime(ev.getEvent())) {
        //kill ourself
       }
       if (opponenttime>ev.getTransaction().getTime(ev.getEvent())) {
        //kill ourself
+       timewasted(ev.getThread(), time);
        reschedule(ev.getThread(), time, 0);
        abortcount++;
        return false;
        reschedule(ev.getThread(), time, 0);
        abortcount++;
        return false;
@@ -525,6 +552,7 @@ public class FlexScheduler extends Thread {
        //kill the opponents
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
        //kill the opponents
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
+         timewasted(thread, time);
          reschedule(thread, time, 0);
          abortcount++;
        }
          reschedule(thread, time, 0);
          abortcount++;
        }
@@ -543,6 +571,7 @@ public class FlexScheduler extends Thread {
       }
       if (ev.getThread()>tid) {
        //kill ourself
       }
       if (ev.getThread()>tid) {
        //kill ourself
+       timewasted(ev.getThread(), time);
        reschedule(ev.getThread(), time, 0);
        abortcount++;
        return false;
        reschedule(ev.getThread(), time, 0);
        abortcount++;
        return false;
@@ -550,6 +579,7 @@ public class FlexScheduler extends Thread {
        //kill the opponents
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
        //kill the opponents
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
+         timewasted(thread, time);
          reschedule(thread, time, 0);
          abortcount++;
        }
          reschedule(thread, time, 0);
          abortcount++;
        }
@@ -576,6 +606,7 @@ public class FlexScheduler extends Thread {
        }
        if (opponenttime>ev.getTransaction().getTime(ev.getEvent())) {
          //kill ourself
        }
        if (opponenttime>ev.getTransaction().getTime(ev.getEvent())) {
          //kill ourself
+         timewasted(ev.getThread(), time);
          reschedule(ev.getThread(), time, 0);
          threadinfo[ev.getThread()].aborted=true;
          abortcount++;
          reschedule(ev.getThread(), time, 0);
          threadinfo[ev.getThread()].aborted=true;
          abortcount++;
@@ -584,6 +615,7 @@ public class FlexScheduler extends Thread {
          //kill the opponents
          for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
            Integer thread=(Integer)thit.next();
          //kill the opponents
          for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
            Integer thread=(Integer)thit.next();
+           timewasted(thread, time);
            reschedule(thread, time, 0);
            threadinfo[thread.intValue()].aborted=true;
            abortcount++;
            reschedule(thread, time, 0);
            threadinfo[thread.intValue()].aborted=true;
            abortcount++;
@@ -593,6 +625,7 @@ public class FlexScheduler extends Thread {
       } else {
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
       } else {
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
+         timewasted(thread, time);
          reschedule(thread, time, 0);
          threadinfo[thread.intValue()].aborted=true;
          abortcount++;
          reschedule(thread, time, 0);
          threadinfo[thread.intValue()].aborted=true;
          abortcount++;
@@ -620,6 +653,7 @@ public class FlexScheduler extends Thread {
        }
        if (opponentthr<tev) {
          //kill ourself
        }
        if (opponentthr<tev) {
          //kill ourself
+         timewasted(ev.getThread(), time);
          reschedule(ev.getThread(), time, 0);
          threadinfo[ev.getThread()].aborted=true;
          abortcount++;
          reschedule(ev.getThread(), time, 0);
          threadinfo[ev.getThread()].aborted=true;
          abortcount++;
@@ -628,6 +662,7 @@ public class FlexScheduler extends Thread {
          //kill the opponents
          for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
            Integer thread=(Integer)thit.next();
          //kill the opponents
          for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
            Integer thread=(Integer)thit.next();
+           timewasted(thread, time);
            reschedule(thread, time, 0);
            threadinfo[thread.intValue()].aborted=true;
            abortcount++;
            reschedule(thread, time, 0);
            threadinfo[thread.intValue()].aborted=true;
            abortcount++;
@@ -637,6 +672,7 @@ public class FlexScheduler extends Thread {
       } else {
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
       } else {
        for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
          Integer thread=(Integer)thit.next();
+         timewasted(thread, time);
          reschedule(thread, time, 0);
          threadinfo[thread.intValue()].aborted=true;
          abortcount++;
          reschedule(thread, time, 0);
          threadinfo[thread.intValue()].aborted=true;
          abortcount++;