1 package gov.nasa.jpf.jvm; 20 21 import gov.nasa.jpf.JPFException; 22 import gov.nasa.jpf.Path; 23 import gov.nasa.jpf.Transition; 24 25 26 32 public class PathScheduler extends Scheduler { 33 Path path; 34 int pos; 35 36 PathScheduler (Path execPath) { 37 path = execPath; 38 pos = 0; 39 } 40 41 public int getRandom () { 42 Transition t = path.get(pos); 43 44 return t.getRandom(); 45 } 46 47 public int getThread () { 48 Transition t = path.get(pos); 49 50 return t.getThread(); 51 } 52 53 public void initialize () { 54 } 55 56 public ThreadInfo locateThread (SystemState ss) { 57 if (pos < path.length()) { 58 Transition t = path.get(pos); 59 int idx = t.getThread(); 60 61 if (idx < ss.getThreadCount()) { 62 ThreadInfo ti = ss.getThreadInfo(idx); 63 64 if (ti.isRunnable()) { 65 return ti; 66 } else { 67 throw new JPFException("no runnable thread in path transition: " + t); 69 } 70 } else { 71 throw new JPFException("invalid thread list index: " + idx); 73 } 74 } 75 76 return null; 78 } 79 80 public void next () { 81 pos++; 83 } 84 85 public int random (int max) { 86 return getRandom(); 87 } 88 } | Popular Tags |