From 6cfcb7346920c28e67c80f2dd3fbe36f6905ed9f Mon Sep 17 00:00:00 2001 From: keznikl Date: Fri, 28 Jun 2013 11:22:29 +0200 Subject: [PATCH] Logging exceptions of Atomic proposition evaluation. JPF scheduler takes max number of process iterations in its constructor. --- .../local/LocalKnowledgeRepositoryJPF.java | 15 +++++++++++++-- .../scheduling/MultithreadedSchedulerJPF.java | 12 +++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/knowledge/local/LocalKnowledgeRepositoryJPF.java b/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/knowledge/local/LocalKnowledgeRepositoryJPF.java index 035fcc308..a11a16dbc 100644 --- a/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/knowledge/local/LocalKnowledgeRepositoryJPF.java +++ b/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/knowledge/local/LocalKnowledgeRepositoryJPF.java @@ -23,6 +23,7 @@ import cz.cuni.mff.d3s.deeco.exceptions.KRExceptionAccessError; import cz.cuni.mff.d3s.deeco.knowledge.ISession; +import cz.cuni.mff.d3s.deeco.logging.Log; import cz.cuni.mff.d3s.deeco.ltl.AtomicProposition; import cz.cuni.mff.d3s.deeco.ltl.CommlinkDEECoJPF; @@ -97,10 +98,13 @@ public Object getSingle(String knowledgeId) { return v.get(0); } + // TODO: manage via runtime event listener mechanism (to be done) instead public void onStart() { evaluatePropositions = true; tryEvaluatePropositions(); } + + // TODO: manage via runtime event listener mechanism (to be done) instead public void onStop() { evaluatePropositions = false; } @@ -109,8 +113,15 @@ private void tryEvaluatePropositions() { if (evaluatePropositions) { for (AtomicProposition ap : propositions) { // propositionToEvaluate.get(...) might return null - if (propositionToEvaluate.get(ap.getName()) == true) - propositionValues.put(ap.getName(), ap.evaluate(this)); + if (propositionToEvaluate.get(ap.getName()) == true) { + boolean value = propositionValues.get(ap.getName()); + try { + value = ap.evaluate(this); + } catch (Exception e) { + Log.e("Atomic proposition evaluation failed (" + ap.getName() + ")."); + } + propositionValues.put(ap.getName(), value); + } } // send names of atomic propositions into JPF diff --git a/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/scheduling/MultithreadedSchedulerJPF.java b/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/scheduling/MultithreadedSchedulerJPF.java index 28dc58adc..4e9bf24ba 100644 --- a/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/scheduling/MultithreadedSchedulerJPF.java +++ b/jdeeco-jpf/src/cz/cuni/mff/d3s/deeco/scheduling/MultithreadedSchedulerJPF.java @@ -19,10 +19,16 @@ public class MultithreadedSchedulerJPF extends Scheduler { private Set threads; - + int maxPeriodIterations = 0; + public MultithreadedSchedulerJPF() { + this(0); + } + + public MultithreadedSchedulerJPF(int maxPeriodIterations) { super(); this.threads = new HashSet(); + this.maxPeriodIterations = maxPeriodIterations; // JPF optimization -> earlier class loading via a clinit call (in the single threaded part) // reduces the state space @@ -43,10 +49,10 @@ public synchronized void start() { //System.out.println("[DEBUG] max period = " + maxPeriod); if (!running) { - // let every process run for the number of times its period P fits into 2*P_max + // let every process run for the number of times its period P fits into maxPeriodIterations*P_max for (SchedulableProcess sp : periodicProcesses) { long spPeriod = ((ProcessPeriodicSchedule) sp.scheduling).interval; - long repeatCount = (2*maxPeriod) / spPeriod + 1; + long repeatCount = (maxPeriodIterations*maxPeriod) / spPeriod + 1; //System.out.println("[DEBUG] period = " + spPeriod + ", repeat count = " + repeatCount);