private final HashSet<String> appSet = new HashSet<String>(); // Apps we want to find their conflicts
private final HashMap<Integer, Node> nodes = new HashMap<Integer, Node>(); // Nodes of a graph
private final DataSet tempSetSet = new DataSet(false, "NA", false, "NA");
+ private long timeout;
+ private long startTime;
volatile private Node parentNode = new Node(-2);
volatile private String operation;
volatile private String detail;
String label;
- public ConflictTracker(Config conf, JPF jpf) {
+ public ConflictTracker(Config config, JPF jpf) {
out = new PrintWriter(System.out, true);
- String[] conflictVars = conf.getStringArray("variables");
+ String[] conflictVars = config.getStringArray("variables");
// We are not tracking anything if it is null
if (conflictVars != null) {
for (String var : conflictVars) {
conflictSet.add(var);
}
}
- String[] apps = conf.getStringArray("apps");
+ String[] apps = config.getStringArray("apps");
// We are not tracking anything if it is null
if (apps != null) {
for (String var : apps) {
appSet.add(var);
}
}
+ // Timeout input from config is in minutes, so we need to convert into millis
+ timeout = config.getInt("timeout", 0) * 60 * 1000;
+ startTime = System.currentTimeMillis();
}
public void setOutSet(Node currentNode) {
@Override
public void instructionExecuted(VM vm, ThreadInfo ti, Instruction nextInsn, Instruction executedInsn) {
+ // Instantiate timeoutTimer
+ if (timeout > 0) {
+ if (System.currentTimeMillis() - startTime > timeout) {
+ StringBuilder sbTimeOut = new StringBuilder();
+ sbTimeOut.append("Execution timeout: " + (timeout / (60 * 1000)) + " minutes have passed!");
+ Instruction nextIns = ti.createAndThrowException("java.lang.RuntimeException", sbTimeOut.toString());
+ ti.setNextPC(nextIns);
+ }
+ }
+
if (conflictFound) {
StringBuilder sb = new StringBuilder();
sb.append("Conflict found between two apps!");