more changes
authorbdemsky <bdemsky>
Fri, 25 Jun 2010 23:51:08 +0000 (23:51 +0000)
committerbdemsky <bdemsky>
Fri, 25 Jun 2010 23:51:08 +0000 (23:51 +0000)
Robust/TransSim/FlexScheduler.java
Robust/TransSim/TransSim.java

index 8fc77ce98b4f4698dfd2cef8063f7e18c59ab0b8..2a050305fe132ff5257cdff6fa52ea47bdc30654 100644 (file)
@@ -82,6 +82,40 @@ public class FlexScheduler extends Thread {
   public static final int ATTACKTIME=12;
   public static final int ATTACKTHREAD=13;
 
+  public static String getName(int policy) {
+    switch (policy) {
+    case LAZY:
+      return new String("LAZY");
+    case COMMIT:
+      return new String("COMMIT");
+    case ATTACK:
+      return new String("ATTACK");
+    case SUICIDE:
+      return new String("SUICIDE");
+    case TIMESTAMP:
+      return new String("TIMESTAMP");
+    case LOCK:
+      return new String("LOCK");
+    case LOCKCOMMIT:
+      return new String("LOCKCOMMIT");
+    case RANDOM:
+      return new String("RANDOM");
+    case KARMA:
+      return new String("KARMA");
+    case POLITE:
+      return new String("POLITE");
+    case ERUPTION:
+      return new String("ERUPTION");
+    case THREAD:
+      return new String("THREAD");
+    case ATTACKTIME:
+      return new String("ATTACKTIME");
+    case ATTACKTHREAD:
+      return new String("ATTACKTHREAD");
+    }
+    return null;
+  }
+
   PriorityQueue eq;
   int policy;
   boolean[] aborted;
index 8e2cb951f2049048519de625a0f65df312663924..22bc2590dd093061a91daba7f1755048364534ad 100644 (file)
@@ -23,131 +23,35 @@ public class TransSim {
 
     Plot p=new Plot("plot");
     Plot pa=new Plot("plotabort");
+    Plot ps=new Plot("plotstall");
+    Plot pb=new Plot("plotbackoff");
+    Plot pat=new Plot("plotaborttime");
+
+    int[] policies=new int[]{FlexScheduler.LAZY, FlexScheduler.COMMIT, FlexScheduler.ATTACK, FlexScheduler.SUICIDE, FlexScheduler.TIMESTAMP, FlexScheduler.LOCK, FlexScheduler.LOCKCOMMIT, FlexScheduler.RANDOM, FlexScheduler.KARMA, FlexScheduler.POLITE, FlexScheduler.ERUPTION, FlexScheduler.THREAD, FlexScheduler.ATTACKTIME, FlexScheduler.ATTACKTHREAD};
 
     for(int i=1;i<40;i++) {
       System.out.println("i="+i);
       numThreads=i;
       Executor e=new Executor(numThreads, numTrans, deltaTrans, numObjects, numAccesses, deltaAccesses, readPercent, delay, deltaDelay, nonTrans, deltaNonTrans, splitobjects, splitaccesses, readPercentSecond);
       System.out.println(e.maxTime());
-      FlexScheduler ls=new FlexScheduler(e, FlexScheduler.LAZY, null);
-      ls.dosim();
-      System.out.println("Lazy Time="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("LAZY").addPoint(i, ls.getTime());
-      pa.getSeries("LAZY").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Lock object accesses
-      ls=new FlexScheduler(e, FlexScheduler.LOCK, abortThreshold, abortRatio, deadlockdepth, null);
-      ls.dosim();
-      System.out.println("Deadlock count="+ls.getDeadLockCount());
-      System.out.println("Lock Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("LOCK").addPoint(i, ls.getTime());
-      pa.getSeries("LOCK").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Lock Commit object accesses
-      ls=new FlexScheduler(e, FlexScheduler.LOCKCOMMIT, abortThreshold, abortRatio, deadlockdepth, null);
-      ls.dosim();
-      System.out.println("Deadlock count="+ls.getDeadLockCount());
-      System.out.println("LockCommit Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("LOCKCOMMIT").addPoint(i, ls.getTime());
-      pa.getSeries("LOCKCOMMIT").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Kill others at commit
-      ls=new FlexScheduler(e, FlexScheduler.COMMIT, null);
-      ls.dosim();
-      System.out.println("Fast Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("COMMIT").addPoint(i, ls.getTime());
-      pa.getSeries("COMMIT").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));      
-
-      //Eager attack
-      ls=new FlexScheduler(e, FlexScheduler.ATTACK, null);
-      ls.dosim();
-      System.out.println("Attack Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("ATTACK").addPoint(i, ls.getTime());
-      pa.getSeries("ATTACK").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Eager polite
-      ls=new FlexScheduler(e, FlexScheduler.SUICIDE, null);
-      ls.dosim();
-      System.out.println("Suicide Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("SUICIDE").addPoint(i, ls.getTime());
-      pa.getSeries("SUICIDE").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Karma
-      ls=new FlexScheduler(e, FlexScheduler.TIMESTAMP, null);
-      ls.dosim();
-      System.out.println("Timestamp Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("TIMESTAMP").addPoint(i, ls.getTime());
-      pa.getSeries("TIMESTAMP").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Karma
-      ls=new FlexScheduler(e, FlexScheduler.RANDOM, null);
-      ls.dosim();
-      System.out.println("Random Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("RANDOM").addPoint(i, ls.getTime());
-      pa.getSeries("RANDOM").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Karma
-      ls=new FlexScheduler(e, FlexScheduler.KARMA, null);
-      ls.dosim();
-      System.out.println("Karma Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("KARMA").addPoint(i, ls.getTime());
-      pa.getSeries("KARMA").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Karma
-      ls=new FlexScheduler(e, FlexScheduler.POLITE, null);
-      ls.dosim();
-      System.out.println("Polit Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("POLITE").addPoint(i, ls.getTime());
-      pa.getSeries("POLITE").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-      //Karma
-      ls=new FlexScheduler(e, FlexScheduler.ERUPTION, null);
-      ls.dosim();
-      System.out.println("Eruption Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("ERUPTION").addPoint(i, ls.getTime());
-      pa.getSeries("ERUPTION").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-
-      //Karma
-      ls=new FlexScheduler(e, FlexScheduler.THREAD, null);
-      ls.dosim();
-      System.out.println("ThreadPriority Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("THPRIORITY").addPoint(i, ls.getTime());
-      pa.getSeries("THPRIORITY").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-
-      //attack time
-      ls=new FlexScheduler(e, FlexScheduler.ATTACKTIME, null);
-      ls.dosim();
-      System.out.println("ThreadPriority Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("ATTACKTIME").addPoint(i, ls.getTime());
-      pa.getSeries("ATTACKTIME").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
-
-
-      //attack thread
-      ls=new FlexScheduler(e, FlexScheduler.ATTACKTHREAD, null);
-      ls.dosim();
-      System.out.println("ThreadPriority Abort="+ls.getTime());
-      System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
-      p.getSeries("ATTACKTHREAD").addPoint(i, ls.getTime());
-      pa.getSeries("ATTACKTHREAD").addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
 
-      //    Scheduler s=new Scheduler(e, besttime);
-      //s.dosim();
-      //System.out.println("Optimal Time="+s.getTime());
+      for(int j=0;j<policies.length;j++) {
+       int policy=policies[j];
+       String policyname=FlexScheduler.getName(policy);
+       FlexScheduler ls=new FlexScheduler(e, policy, null);
+       ls.dosim();
+       System.out.println("Deadlock count="+ls.getDeadLockCount());
+       System.out.println(policyname+" Time="+ls.getTime());
+       System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
+       System.out.println("Stalltime="+ls.getStallTime()+" Backofftime="+ls.getBackoffTime());
+       System.out.println("Aborttime="+ls.getAbortedTime());
+       
+       p.getSeries(policyname).addPoint(i, ls.getTime());
+       pa.getSeries(policyname).addPoint(i, 100.0*((double)ls.getAborts())/((double)(ls.getAborts()+ls.getCommits())));
+       ps.getSeries(policyname).addPoint(i, ls.getStallTime());
+       pb.getSeries(policyname).addPoint(i, ls.getBackoffTime());
+       pat.getSeries(policyname).addPoint(i, ls.getAbortedTime());
+      }
     }
     p.close();
     pa.close();