private void Search(State st) { searchStack.Push(stateSet.GetStateId(st)); int t1 = 0; int t2 = st.GetForwardStateCount() - 1; if (CheckerConfiguration.DoPOR) { for (int i = 0; i < st.ThreadCount; i++) { int[] trans = st.GetThreadTransitions(i); if (trans.Length == 0) goto nextThread; for (int j = 0; j < trans.Length; j++) if (st.IsForwardEscaping(trans[j]) == true) goto nextThread; // now we found a potential ample set, must check C3 condition t1 = trans[0]; t2 = trans[trans.Length - 1]; for(int j = t1; j <= t2; j++) { State stnew = st.Duplicate(); stnew.Forward(j); if(stateSet.HasState(stnew)) { int k = stateSet.GetStateId(stnew); for (int u = 0; u < searchStack.Count; u++) if(searchStack[u] == k) goto nextThread; //unfortunately this new state is on the search stack } } nAmpleFound++; goto foundAmple; nextThread: ; } nNoAmpleFound++; foundAmple: ; } for (int i = t1; i <= t2; i++) { State stnew = st.Duplicate(); stnew.Forward(i); if(stnew.IsDeadLock) stnew.Report(-2); bool visited = stateSet.HasState(stnew); if (visited == false) stateSet.AddState(stnew); if (st.IsForwardReordering(i) != null) mfGraph.AddEdge(stateSet.GetStateId(st), stateSet.GetStateId(stnew), 1, st.IsForwardReordering(i)); else mfGraph.AddEdge(stateSet.GetStateId(st), stateSet.GetStateId(stnew), 100000000, null); if (stnew.IsEndState == true) { mfGraph.GetVertex(stateSet.GetStateId(stnew)).PropertyValue = stnew.ReportedValue; if(CheckerConfiguration.DoTiming) Console.WriteLine(DateTime.Now.Subtract(startTime)); }else if (visited == false) Search(stnew); } searchStack.Pop(); }
public static void Search(State st) { if(stateSet.HasState(st)) return; stateSet.AddState(st); int n = st.GetForwardStateCount(); for(int i = 0; i < n; i++) { State stnew = st.Duplicate(); stnew.Forward(i); if(stnew.IsDeadLock) stnew.Report(-1); Search(stnew); } }
public static void FindGoodState(State st) { int n = st.GetForwardStateCount(); bool visited; for(int i = 0; i < n; i++) if(st.IsForwardReordering(i) == null) { State stnew = st.Duplicate(); stnew.Forward(i); if(stnew.IsDeadLock) stnew.Report(-1); visited = stateSet.HasState(stnew); if(visited == false) { stateSet.AddState(stnew); if(stnew.IsEndState == true) { foreach(int x in goodReportedValues) if(x == stnew.ReportedValue) goto nexti; goodReportedValues.Add(stnew.ReportedValue); } else { FindGoodState(stnew); } } nexti:; } }
public static void GuidedSearch(State state) { string path = CheckerConfiguration.GetProperty("guided_path"); Strtok st = new Strtok(path); while(true) { string sc = st.NextToken(); if(sc == null) break; int choice = Int32.Parse(sc); if(choice < state.GetForwardStateCount()) { DelayedAction da = state.IsForwardReordering(choice); state.Forward(choice); if(CheckerConfiguration.DoPrintExecution) if(da != null) Console.WriteLine("Reordered: " + da.SourceInstruction.ToString()); } else { Console.WriteLine("wrong path is supplied"); break; } } }
public static void FindFirstBadState(State st) { int n = st.GetForwardStateCount(); bool visited; for(int i = 0; i < n; i++) { State stnew = st.Duplicate(); stnew.Forward(i); if(stnew.IsDeadLock) stnew.Report(-1); visited = stateSet.HasState(stnew); if(visited == false) { stateSet.AddState(stnew); if(stnew.IsEndState == true) { foreach(int x in goodReportedValues) if(x == stnew.ReportedValue) goto skip1; badState = stateSet.GetStateId(stnew); return; skip1: ; } } if(st.IsForwardReordering(i) != null) { CILInstruction inst = (st.IsForwardReordering(i)).SourceInstruction; if(possibleLocations.ContainsKey(inst.ID) == false) possibleLocations.Add(inst.ID, inst); } if((visited == false) && (stnew.IsEndState == false)) if(badState == -1) // break the recursion if we found bad state FindFirstBadState(stnew); } }