Mercurial > hg > Members > kono > jpf-core
changeset 13:9d0c3f9df6e0
replaced ThreadInfo.yield() (which was bypassing SyncPolicy) with SyncPolicy.setsRescheduleCG(). The current use is only for the corner case where the last transition in the last non-daemon triggers a defect in a still runnable daemon, which we want to detect before the daemon is shut down.
Added ChoiceGenerator.set/getStateId(), which is set on the nextCg once we broke a transition and performed state matching. This can be used to determine the states in the current path without having to maintain this as a separate structure that just mirrors the CG path. There is always a 1:1 relationship between the state that caused the CG and the respective CG instance.
author | Peter Mehlitz <Peter.C.Mehlitz@nasa.gov> |
---|---|
date | Fri, 13 Mar 2015 14:07:43 -0700 |
parents | a51545ab397e |
children | 7ba603d4ba20 |
files | src/main/gov/nasa/jpf/listener/IdleFilter.java src/main/gov/nasa/jpf/vm/ChoiceGenerator.java src/main/gov/nasa/jpf/vm/ChoiceGeneratorBase.java src/main/gov/nasa/jpf/vm/SystemState.java src/main/gov/nasa/jpf/vm/ThreadInfo.java |
diffstat | 5 files changed, 27 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/gov/nasa/jpf/listener/IdleFilter.java Wed Mar 11 18:20:32 2015 -0700 +++ b/src/main/gov/nasa/jpf/listener/IdleFilter.java Fri Mar 13 14:07:43 2015 -0700 @@ -202,7 +202,7 @@ case YIELD: // give other threads a chance to run brokeTransition = true; - ti.yield(); + ti.reschedule("rescheduleIdleLoop"); log.warning("yield on suspicious loop in thread: " + ti.getName() + "\n\tat " + ci.getName() + "." + mi.getName() + "(" + file + ":" + line + ")");
--- a/src/main/gov/nasa/jpf/vm/ChoiceGenerator.java Wed Mar 11 18:20:32 2015 -0700 +++ b/src/main/gov/nasa/jpf/vm/ChoiceGenerator.java Fri Mar 13 14:07:43 2015 -0700 @@ -119,6 +119,10 @@ void setContext(ThreadInfo tiCreator); + void setStateId (int stateId); + + int getStateId (); + String getSourceLocation(); boolean supportsReordering();
--- a/src/main/gov/nasa/jpf/vm/ChoiceGeneratorBase.java Wed Mar 11 18:20:32 2015 -0700 +++ b/src/main/gov/nasa/jpf/vm/ChoiceGeneratorBase.java Fri Mar 13 14:07:43 2015 -0700 @@ -62,6 +62,9 @@ // the instruction that created this CG protected Instruction insn; + // the state id of the state in which the CG was created + protected int stateId; + // and the thread that executed this insn protected ThreadInfo ti; @@ -172,6 +175,20 @@ ti = tiCreator; insn = tiCreator.getPC(); } + + @Override + public void setStateId(int stateId){ + this.stateId = stateId; + + if (isCascaded){ + getCascadedParent().setStateId(stateId); + } + } + + @Override + public int getStateId(){ + return stateId; + } @Override public String getSourceLocation() {
--- a/src/main/gov/nasa/jpf/vm/SystemState.java Wed Mar 11 18:20:32 2015 -0700 +++ b/src/main/gov/nasa/jpf/vm/SystemState.java Fri Mar 13 14:07:43 2015 -0700 @@ -264,6 +264,10 @@ public void setId (int newId) { id = newId; trail.setStateId(newId); + + if (nextCg != null){ + nextCg.setStateId(newId); + } } public void recordSteps (boolean cond) {
--- a/src/main/gov/nasa/jpf/vm/ThreadInfo.java Wed Mar 11 18:20:32 2015 -0700 +++ b/src/main/gov/nasa/jpf/vm/ThreadInfo.java Fri Mar 13 14:07:43 2015 -0700 @@ -2305,7 +2305,7 @@ // is the last operation in the daemon since a host VM might preempt // on every instruction, not just CG insns (see .test.mc.DaemonTest) if (vm.getThreadList().hasOnlyMatchingOtherThan(this, vm.getDaemonRunnablePredicate())) { - if (yield()) { + if (scheduler.setsRescheduleCG(this, "daemonTermination")) { return false; } } @@ -3211,22 +3211,6 @@ BreakGenerator cg = new BreakGenerator(reason, this, false); return ss.setNextChoiceGenerator(cg); // this breaks the transition } - - /** - * this is like a reschedule request, but gives the scheduler an option to skip the CG - */ - public boolean yield() { - SystemState ss = vm.getSystemState(); - - if (!ss.isIgnored()){ - ThreadInfo[] choices = vm.getThreadList().getAllMatching(vm.getAppTimedoutRunnablePredicate()); - ThreadChoiceFromSet cg = new ThreadChoiceFromSet( "yield", choices, true); - - return ss.setNextChoiceGenerator(cg); // this breaks the transition - } - - return false; - } /** * this breaks the current transition with a CG that forces an end state (i.e.