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();
        }
Beispiel #2
0
        public static void FindBadState(State st)
        {
            bool visited;

            int t1 = 0, t2 = st.ThreadCount - 1;

            for(int i = t1; i <= t2; i++)
            {
                int[] trans = st.GetThreadTransitions(i);
                for (int j = 0; j < trans.Length; j++)
                {
                    State stnew = st.Duplicate();
                    stnew.Forward(trans[j]);
                    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);
                        skip1: ;
                        }
                    }

                    if (st.IsForwardReordering(trans[j]) != null)
                    {
                        CILInstruction inst = (st.IsForwardReordering(trans[j])).SourceInstruction;
                        if (possibleLocations.ContainsKey(inst.ID) == false)
                            possibleLocations.Add(inst.ID, inst);
                    }

                    if ((visited == false) && (stnew.IsEndState == false))
                        FindBadState(stnew);
                }
            }
        }