print more data
[IRC.git] / Robust / TransSim / FileSim.java
1 public class FileSim {
2   public static void p1(Executor e) throws Exception {
3     FlexScheduler ls=new FlexScheduler(e, FlexScheduler.LAZY, null);
4     ls.start();
5
6     //Kill others at commit
7     FlexScheduler ls4=new FlexScheduler(e, FlexScheduler.COMMIT, null);
8     ls4.start();
9
10     FlexScheduler ls5=new FlexScheduler(e, FlexScheduler.ATTACK, null);
11     ls5.start();
12
13
14     ls.join();
15     System.out.println("Lazy Time="+ls.getTime());
16     System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits());
17     System.out.println("Stalltime="+ls.getStallTime()+" Backofftime="+ls.getBackoffTime());
18     ls=null;
19
20     ls4.join();
21     System.out.println("Fast Abort="+ls4.getTime());
22     System.out.println("Aborts="+ls4.getAborts()+" Commit="+ls4.getCommits());
23     System.out.println("Stalltime="+ls4.getStallTime()+" Backofftime="+ls4.getBackoffTime());
24     ls4=null;
25
26     ls5.join();
27     System.out.println("Attack Abort="+ls5.getTime());
28     System.out.println("Aborts="+ls5.getAborts()+" Commit="+ls5.getCommits());
29     System.out.println("Stalltime="+ls5.getStallTime()+" Backofftime="+ls5.getBackoffTime());
30     ls5=null;
31   }
32
33   public static void p2(Executor e) throws Exception {
34     FlexScheduler ls6=new FlexScheduler(e, FlexScheduler.SUICIDE, null);
35     ls6.start();
36     
37     FlexScheduler ls7=new FlexScheduler(e, FlexScheduler.TIMESTAMP, null);
38     ls7.start();
39
40     FlexScheduler ls8=new FlexScheduler(e, FlexScheduler.RANDOM, null);
41     ls8.start();
42
43
44     ls6.join();
45     System.out.println("Suicide Abort="+ls6.getTime());
46     System.out.println("Aborts="+ls6.getAborts()+" Commit="+ls6.getCommits());
47     System.out.println("Stalltime="+ls6.getStallTime()+" Backofftime="+ls6.getBackoffTime());
48     ls6=null;
49
50     ls7.join();
51     System.out.println("Timestamp Abort="+ls7.getTime());
52     System.out.println("Aborts="+ls7.getAborts()+" Commit="+ls7.getCommits());
53     System.out.println("Stalltime="+ls7.getStallTime()+" Backofftime="+ls7.getBackoffTime());
54     ls7=null;
55
56     ls8.join();
57     System.out.println("Random Abort="+ls8.getTime());
58     System.out.println("Aborts="+ls8.getAborts()+" Commit="+ls8.getCommits());
59     System.out.println("Stalltime="+ls8.getStallTime()+" Backofftime="+ls8.getBackoffTime());
60     ls8=null;
61   }
62
63   public static void p3(Executor e) throws Exception {
64     FlexScheduler ls9=new FlexScheduler(e, FlexScheduler.KARMA, null);
65     ls9.start();
66
67     FlexScheduler ls10=new FlexScheduler(e, FlexScheduler.POLITE, null);
68     ls10.start();
69
70     FlexScheduler ls11=new FlexScheduler(e, FlexScheduler.ERUPTION, null);
71     ls11.start();
72
73
74
75     ls9.join();
76     System.out.println("Karma Abort="+ls9.getTime());
77     System.out.println("Aborts="+ls9.getAborts()+" Commit="+ls9.getCommits());
78     System.out.println("Stalltime="+ls9.getStallTime()+" Backofftime="+ls9.getBackoffTime());
79     ls9=null;
80
81     ls10.join();
82     System.out.println("Polite Abort="+ls10.getTime());
83     System.out.println("Aborts="+ls10.getAborts()+" Commit="+ls10.getCommits());
84     System.out.println("Stalltime="+ls10.getStallTime()+" Backofftime="+ls10.getBackoffTime());
85     ls10=null;
86
87     ls11.join();
88     System.out.println("Eruption Abort="+ls11.getTime());
89     System.out.println("Aborts="+ls11.getAborts()+" Commit="+ls11.getCommits());
90     System.out.println("Stalltime="+ls11.getStallTime()+" Backofftime="+ls11.getBackoffTime());
91   }
92
93   public static void p4(Executor e) throws Exception {
94     FlexScheduler ls12=new FlexScheduler(e, FlexScheduler.THREAD, null);
95     ls12.start();
96     FlexScheduler ls13=new FlexScheduler(e, FlexScheduler.ATTACKTIME, null);
97     ls13.start();
98     FlexScheduler ls14=new FlexScheduler(e, FlexScheduler.ATTACKTHREAD, null);
99     ls14.start();
100
101     ls12.join();
102     System.out.println("ThreadPriority Abort="+ls12.getTime());
103     System.out.println("Aborts="+ls12.getAborts()+" Commit="+ls12.getCommits());
104     System.out.println("Stalltime="+ls12.getStallTime()+" Backofftime="+ls12.getBackoffTime());
105     ls12=null;
106
107     ls13.join();
108     System.out.println("AttackTime Abort="+ls13.getTime());
109     System.out.println("Aborts="+ls13.getAborts()+" Commit="+ls13.getCommits());
110     System.out.println("Stalltime="+ls13.getStallTime()+" Backofftime="+ls13.getBackoffTime());
111     ls13=null;
112
113     ls14.join();
114     System.out.println("AttackThread Abort="+ls14.getTime());
115     System.out.println("Aborts="+ls14.getAborts()+" Commit="+ls14.getCommits());
116     System.out.println("Stalltime="+ls14.getStallTime()+" Backofftime="+ls14.getBackoffTime());
117     ls14=null;
118   }
119
120   public static void main(String[] args) throws Exception {
121     //time between transactions
122     //split objects
123     int splitobjects=100;//10 percent of objects special
124     int splitaccesses=100;//40 percent of accesses to special objects
125     int abortThreshold=0; //need 4 aborts to declare risky
126     int abortRatio=0;//need 40% aborts vs commits to declare risky
127     int deadlockdepth=10;
128
129     String filename=args[0];
130     Executor e=new Executor(filename);
131     System.out.println(e.maxTime());
132     if (args.length==1||args[1].equals("1"))
133       p1(e);
134     if (args.length==1||args[1].equals("2"))
135       p2(e);
136     if (args.length==1||args[1].equals("3"))
137       p3(e);
138     if (args.length==1||args[1].equals("4"))
139       p4(e);
140   }
141 }