}
}
+ int lowid=0;
+ int countlow=0;
+
Plot p;
Series serCommit;
Series serStart;
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("TIMID");
+ 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;
long shorttesttime;
+ long earliesttime=-1;
long starttime=-1;
Hashtable rdobjmap;
Hashtable wrobjmap;
return commitcount;
}
+ public long getEarliestTime() {
+ return earliesttime-starttime;
+ }
+
public long getTime() {
return shorttesttime-starttime;
}
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);
+ if (e.isStalled()) {
+ stallcycles-=timeleft; //this time is no longer stalled...back it out
+ timeleft=0;//if the event is stalled, we already waited this time...
+ }
+ long totaltime=trans.getTime(eIndex);
totaltime-=timeleft;//subtract off time to the next event
abortedcycles+=totaltime;
}
public void stall(Event ev, long time, long delay) {
stallcycles+=delay;
ev.setTime(time+delay);
+ ev.setStall();
eq.add(ev);
}
//ready to commit this one
long currtime=ev.getTime();
releaseObjects(trans, ev.getThread(), currtime);
+
+ if (ev.getThread()==lowid) {
+ countlow++;
+ if (countlow==4) {
+ countlow=0;
+ lowid++;
+ if (lowid==e.numThreads())
+ lowid=0;
+ }
+ }
//See if we have been flagged as aborted for the lazy case
boolean abort=aborted[ev.getThread()];
Event nev=new Event(currtime+nexttrans.getTime(0), nexttrans, 0, ev.getThread(), nexttransnum);
currentevents[ev.getThread()]=nev;
eq.add(nev);
+ } else {
+ if (earliesttime==-1)
+ earliesttime=currtime;
}
}
return conflictset;
}
+
+ int normalize(int tid) {
+ int newtid=tid-lowid;
+ if (newtid<0)
+ newtid+=e.numThreads();
+ return newtid;
+ }
+
public Set wrConflictSet(int thread, ObjIndex obj) {
HashSet conflictset=new HashSet();
if (rdobjmap.containsKey(obj)) {
Integer thread=(Integer)thit.next();
Event other=currentevents[thread.intValue()];
int eventnum=other.getEvent();
- long otid=thread.intValue();
+ long otid=normalize(thread.intValue());
if (tid>otid)
tid=otid;
}
- if (ev.getThread()>tid) {
+ if (normalize(ev.getThread())>tid) {
//kill ourself
timewasted(ev.getThread(), time);
reschedule(ev.getThread(), time, 0);
Transaction t;
int threadid;
int transnum;
+ boolean stalled;
+
+ public boolean isStalled() {
+ return stalled;
+ }
+
+ public void setStall() {
+ stalled=true;
+ }
public void makeInvalid() {
valid=false;