From aae7932978c7765a3da50b1eb7cfcbf703d8ad4a Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 25 Jun 2010 23:16:32 +0000 Subject: [PATCH] changes --- Robust/TransSim/FileSim.java | 12 ++++++++++ Robust/TransSim/FlexScheduler.java | 36 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/Robust/TransSim/FileSim.java b/Robust/TransSim/FileSim.java index 8baca55c..68b19c76 100644 --- a/Robust/TransSim/FileSim.java +++ b/Robust/TransSim/FileSim.java @@ -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("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()); + 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()); + System.out.println("Abortedtime="+ls5.getAbortedTime()); 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("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()); + 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()); + System.out.println("Abortedtime="+ls8.getAbortedTime()); 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("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()); + 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()); + System.out.println("Abortedtime="+ls11.getAbortedTime()); } 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("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()); + 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()); + System.out.println("Abortedtime="+ls14.getAbortedTime()); ls14=null; } diff --git a/Robust/TransSim/FlexScheduler.java b/Robust/TransSim/FlexScheduler.java index af8f40d8..8fc77ce9 100644 --- a/Robust/TransSim/FlexScheduler.java +++ b/Robust/TransSim/FlexScheduler.java @@ -136,6 +136,24 @@ public class FlexScheduler extends Thread { 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; @@ -320,6 +338,7 @@ public class FlexScheduler extends Thread { serAbort.addPoint(currtime, threadid); } else if (policy==COMMIT||policy==LOCKCOMMIT) { //abort it immediately + timewasted(threadid, currtime); reschedule(threadid, currtime, 0); abortcount++; } @@ -328,6 +347,7 @@ public class FlexScheduler extends Thread { } } else { abortcount++; + timewasted(ev.getThread(), currtime); } //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(); + timewasted(thread, time); 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]); + timewasted(thread, time); 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]); + timewasted(thread, time); 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(); + timewasted(thread, time); 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(); + timewasted(thread, time); 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) { + timewasted(ev.getThread(), time); 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 + timewasted(ev.getThread(), time); 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(); + timewasted(thread, time); reschedule(thread, time, 0); abortcount++; } @@ -543,6 +571,7 @@ public class FlexScheduler extends Thread { } if (ev.getThread()>tid) { //kill ourself + timewasted(ev.getThread(), time); 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(); + timewasted(thread, time); reschedule(thread, time, 0); abortcount++; } @@ -576,6 +606,7 @@ public class FlexScheduler extends Thread { } if (opponenttime>ev.getTransaction().getTime(ev.getEvent())) { //kill ourself + timewasted(ev.getThread(), time); 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(); + timewasted(thread, time); 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(); + timewasted(thread, time); reschedule(thread, time, 0); threadinfo[thread.intValue()].aborted=true; abortcount++; @@ -620,6 +653,7 @@ public class FlexScheduler extends Thread { } if (opponentthr