ls9.join();
System.out.println("Karma Abort="+ls9.getTime());
System.out.println("Aborts="+ls9.getAborts()+" Commit="+ls9.getCommits());
+ System.out.println("atime="+ls9.aborttime+" stalltime="+ls9.stalltime);
ls9=null;
ls10.join();
ls11.join();
System.out.println("Eruption Abort="+ls11.getTime());
+ System.out.println("atime="+ls11.aborttime+" stalltime="+ls11.stalltime);
System.out.println("Aborts="+ls11.getAborts()+" Commit="+ls11.getCommits());
}
+ public static void p4(Executor e) throws Exception {
+ FlexScheduler ls9=new FlexScheduler(e, FlexScheduler.THREAD, null);
+ ls9.start();
+
+ ls9.join();
+ System.out.println("Karma Abort="+ls9.getTime());
+ System.out.println("Aborts="+ls9.getAborts()+" Commit="+ls9.getCommits());
+ System.out.println("atime="+ls9.aborttime+" stalltime="+ls9.stalltime);
+ ls9=null;
+ }
+
public static void main(String[] args) throws Exception {
//time between transactions
//split objects
p2(e);
if (args.length==1||args[1].equals("3"))
p3(e);
+ if (args.length==1||args[1].equals("4"))
+ p4(e);
}
}
\ No newline at end of file
public static final int KARMA=8;
public static final int POLITE=9;
public static final int ERUPTION=10;
+ public static final int THREAD=11;
PriorityQueue eq;
int policy;
boolean[] blocked;
public boolean isEager() {
- return policy==ATTACK||policy==SUICIDE||policy==TIMESTAMP||policy==RANDOM||policy==KARMA||policy==POLITE||policy==ERUPTION;
+ return policy==ATTACK||policy==SUICIDE||policy==TIMESTAMP||policy==RANDOM||policy==KARMA||policy==POLITE||policy==ERUPTION||policy==THREAD;
}
public boolean countObjects() {
//Takes as parameter -- current transaction read event ev, conflicting
//set of threads, and the current time
//Returning false causes current transaction not continue to be scheduled
+ long stalltime=0;
+ long aborttime=0;
+
public boolean handleConflicts(Event ev, Set threadstokill, long time) {
if (policy==RANDOM) {
//stall for a little while
threadinfo[ev.getThread()].priority--;
retrycount[ev.getThread()]++;
- stall(ev, time+r.nextInt(3000));
+ int rtime=r.nextInt(3000);
+ stall(ev, time+rtime);
+ stalltime+=rtime;
return false;
} else {
//we win
int dback=backoff[thread]*2;
if (dback>0)
backoff[thread]=dback;
- reschedule(thread, time+r.nextInt(backoff[thread]));
+ int atime=r.nextInt(backoff[thread]);
+ reschedule(thread, time+atime);
+ aborttime+=atime;
abortcount++;
}
return true;
//we lose
threadinfo[ev.getThread()].priority--;
//stall for a little while
- stall(ev, time+r.nextInt(3000));
+ int rtime=r.nextInt(3000);
+ stall(ev, time+rtime);
+ stalltime+=rtime;
int ourpriority=threadinfo[ev.getThread()].priority;
ourpriority-=transferred[ev.getThread()];
for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
int dback=backoff[thread]*2;
if (dback>0)
backoff[thread]=dback;
- reschedule(thread, time+r.nextInt(backoff[thread]));
+ int atime=r.nextInt(backoff[thread]);
+ reschedule(thread, time+atime);
+ aborttime+=atime;
abortcount++;
}
return true;
}
return true;
}
+ } else if (policy==TIMESTAMP) {
+ long opponenttime=0;
+
+ for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
+ Integer thread=(Integer)thit.next();
+ Event other=currentevents[thread.intValue()];
+ int eventnum=other.getEvent();
+ long otime=other.getTransaction().getTime(other.getEvent());
+ if (otime>opponenttime)
+ opponenttime=otime;
+ }
+ if (opponenttime>ev.getTransaction().getTime(ev.getEvent())) {
+ //kill ourself
+ reschedule(ev.getThread(), time+r.nextInt(backoff[ev.getThread()]));
+ abortcount++;
+ return false;
+ } else {
+ //kill the opponents
+ for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
+ Integer thread=(Integer)thit.next();
+ reschedule(thread, time+r.nextInt(backoff[thread.intValue()]));
+ abortcount++;
+ }
+ return true;
+ }
+ } else if (policy==THREAD) {
+ long tid=1000;
+
+ for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
+ Integer thread=(Integer)thit.next();
+ Event other=currentevents[thread.intValue()];
+ int eventnum=other.getEvent();
+ long otid=thread.intValue();
+ if (tid>otid)
+ tid=otid;
+ }
+ if (ev.getThread()>tid) {
+ //kill ourself
+ reschedule(ev.getThread(), time+r.nextInt(backoff[ev.getThread()]));
+ abortcount++;
+ return false;
+ } else {
+ //kill the opponents
+ for(Iterator thit=threadstokill.iterator();thit.hasNext();) {
+ Integer thread=(Integer)thit.next();
+ reschedule(thread, time+r.nextInt(backoff[thread.intValue()]));
+ abortcount++;
+ }
+ return true;
+ }
}
+
//Not eager
return true;
}