Exemplo n.º 1
0
        public ExecutionState(StateImpl s, TraversalInfo predecessor, Via bt,
            bool MustFingerprint)
            : base(s, StateType.ExecutionState, predecessor, bt)
        {
            Debug.Assert(ProcessInfo != null &&
                        ProcessInfo.Length == NumProcesses);

            stateImpl = s;
            hasMultipleSuccessors = NumSuccessors() > 1;
            receipt = s.CheckIn();

            if (!ZingerConfiguration.DoRandomSampling)
            {
                if (MustFingerprint)
                {
                    this.fingerprint = s.Fingerprint;
                    this.IsFingerPrinted = true;
                }
                else
                {
                    this.fingerprint = null;
                    this.IsFingerPrinted = false;
                }
            }
        }
Exemplo n.º 2
0
        public static void PrintTrace(Via[] bts)
        {
            int len = bts.Length;
            int i;

            Console.Write("{0} transitions: ", len);
            for (i = 0; i < len; i++)
                Console.Write(bts[i].ToString());
            Console.WriteLine("");
        }
Exemplo n.º 3
0
        public ExecutionState(StateImpl s, TraversalInfo predecessor, Via bt)
            : base(s, StateType.ExecutionState, predecessor, bt)
        {
            Debug.Assert(ProcessInfo != null &&
                ProcessInfo.Length == NumProcesses);
            hasMultipleSuccessors = NumSuccessors() > 1;
            stateImpl = s;
            currProcess = 0;
            receipt = s.CheckIn();

            #if true
            //dont fingerprint during random sampling
            if (!ZingerConfiguration.DoRandomSampling)
            {
                if (ZingerConfiguration.FingerprintSingleTransitionStates)
                {
                    if (this.NumProcesses > 1)
                    {
                        this.fingerprint = s.Fingerprint;
                        this.IsFingerPrinted = true;
                    }
                    else
                    {
                        // Fingerprint with probability p
                        if (ZingerUtilities.rand.NextDouble() <= ZingerConfiguration.NonChooseProbability)
                        {
                            this.fingerprint = s.Fingerprint;
                            this.IsFingerPrinted = true;
                        }
                        else
                        {
                            this.fingerprint = null;
                            this.IsFingerPrinted = false;
                        }
                    }
                }
                else
                {
                    this.fingerprint = s.Fingerprint;
                    this.IsFingerPrinted = true;
                }
            }
            #endif
        }
Exemplo n.º 4
0
        protected override void Replay(TraversalInfo succ, Via bt)
        {
            ViaChoose vc = (ViaChoose)bt;

            StateImpl s = this.reclaimState();
            s.RunChoice(vc.ChoiceNumber);
            succ.deOrphanize(s);
        }
Exemplo n.º 5
0
        public ChooseState(StateImpl s, TraversalInfo predecessor,
            Via bt, bool MustFingerprint)
            : base(s, StateType.ChooseState, predecessor, bt)
        {
            numChoices = s.NumChoices;
            stateImpl = s;
            hasMultipleSuccessors = s.NumChoices > 1;

            receipt = s.CheckIn();
            if (!ZingerConfiguration.DoRandomSampling)
            {
                if (MustFingerprint)
                {
                    fingerprint = s.Fingerprint;
                    this.IsFingerPrinted = true;
                }
                else
                {
                    this.fingerprint = null;
                    this.IsFingerPrinted = false;
                }
            }
        }
Exemplo n.º 6
0
        public ChooseState(StateImpl s,
            TraversalInfo predecessor, Via bt)
            : base(s, StateType.ChooseState, predecessor, bt)
        {
            numChoices = s.NumChoices;
            hasMultipleSuccessors = s.NumChoices > 1;

            stateImpl = s;

            receipt = s.CheckIn();
            if (!ZingerConfiguration.DoRandomSampling)
            {
                if (ZingerConfiguration.FingerprintSingleTransitionStates)
                {
                    if (this.NumChoices > 1)
                    {
                        this.fingerprint = s.Fingerprint;
                        this.IsFingerPrinted = true;
                    }
                    else
                    {
                        // Fingerprint with probability p
                        if (ZingerUtilities.rand.NextDouble() <= ZingerConfiguration.NonChooseProbability)
                        {
                            this.fingerprint = s.Fingerprint;
                            this.IsFingerPrinted = true;
                        }
                        else
                        {
                            this.fingerprint = null;
                            this.IsFingerPrinted = false;
                        }
                    }
                }
                else
                {
                    this.fingerprint = s.Fingerprint;
                    this.IsFingerPrinted = true;
                }
            }
        }
Exemplo n.º 7
0
 protected override void Replay(TraversalInfo succ, Via bt)
 {
     throw new ArgumentException("cannot replay from a terminal node");
 }
Exemplo n.º 8
0
        public TerminalState(StateImpl s, TraversalInfo pred, Via bt,
            bool MustFingerprint)
            : base(s, StateType.TerminalState, pred, bt)
        {
            hasMultipleSuccessors = false;
            if (s.IsErroneous)
            {
                IsErroneous = true;
                Error = s.Exception;
            }
            else if (s.IsFailedAssumption)
            {
                IsFailedAssumption = true;
                Error = s.Exception;
            }
            else if (s.IsValidTermination)
            {
                IsValidTermination = true;
            }

            stateImpl = s;
            receipt = s.CheckIn();

            if (MustFingerprint)
            {
                this.fingerprint = s.Fingerprint;
                this.IsFingerPrinted = true;
            }
            else
            {
                this.fingerprint = null;
                this.IsFingerPrinted = false;
            }
        }
Exemplo n.º 9
0
        public TerminalState(StateImpl s, TraversalInfo pred, Via bt)
            : base(s, StateType.TerminalState, pred, bt)
        {
            hasMultipleSuccessors = false;
            if (s.IsErroneous)
            {
                IsErroneous = true;
                Error = s.Exception;
            }
            else if (s.IsFailedAssumption)
            {
                IsFailedAssumption = true;
                Error = s.Exception;
            }
            else if (s.IsValidTermination)
            {
                IsValidTermination = true;
            }

            stateImpl = s;

            receipt = s.CheckIn();

            #if true
            if (ZingerConfiguration.FingerprintSingleTransitionStates)
            {
                // Fingerprint with probability p
                if (ZingerUtilities.rand.NextDouble() <= ZingerConfiguration.NonChooseProbability)
                {
                    this.fingerprint = s.Fingerprint;
                    this.IsFingerPrinted = true;
                }
                else
                {
                    this.fingerprint = null;
                    this.IsFingerPrinted = false;
                }
            }
            else
            {
                this.fingerprint = s.Fingerprint;
                this.IsFingerPrinted = true;
            }
            #endif
        }
Exemplo n.º 10
0
        protected override void Replay(TraversalInfo succ, Via bt)
        {
            ViaExecute ve = (ViaExecute)bt;

            StateImpl s = this.reclaimState();
            s.RunProcess(ve.ProcessExecuted);
            succ.deOrphanize(s);
        }
Exemplo n.º 11
0
 protected abstract void Replay(TraversalInfo succ, Via bt);
Exemplo n.º 12
0
        protected static TraversalInfo MakeTraversalInfo(StateImpl s, TraversalInfo pred,
            Via bt, bool MustFingerprint)
        {
            if (s.IsTerminalState)
                return new TerminalState(s, pred, bt, MustFingerprint);
            if (s.IsChoicePending)
                return new ChooseState(s, pred, bt, MustFingerprint);
            if (s.IsNormalState)
                return new ExecutionState(s, pred, bt, MustFingerprint);

            Debug.Fail("unexpected state type");
            return null;
        }
Exemplo n.º 13
0
        protected TraversalInfo(StateImpl s, StateType st,
            TraversalInfo pred, Via bt)
        {
            stateType = st;
            Via = bt;
            NumProcesses = s.NumProcesses;
            ProcessInfo = s.GetProcessInfo();
            events = s.GetEvents();
            exception = s.Exception;
            IsAcceptingState = s.IsAcceptingState;

            //initialize the plugin information.

            if (pred != null)
            {
                Predecessor = pred;
                CurrentDepth = pred.CurrentDepth + 1;
                zBounds = new ZingerBounds(pred.zBounds.ExecutionCost, pred.zBounds.ChoiceCost);
                zBounds.IncrementDepthCost();

                doDelay = false;
                if (ZingerConfiguration.DoDelayBounding)
                {
                    ZingDBSchedState = s.ZingDBSchedState;
                    ZingDBScheduler = s.ZingDBScheduler;
                }
                else if (ZingerConfiguration.DoPreemptionBounding)
                {
                    preemptionBounding = new ZingPreemptionBounding(ProcessInfo, NumProcesses, Predecessor.preemptionBounding.currentProcess);
                }

                if (ZingerConfiguration.DronacharyaEnabled || ZingerConfiguration.IsPluginEnabled)
                {
                    ZingerPlugin = s.ZingerPlugin;
                    ZingerPluginState = s.ZingerPluginState;
                }
                pred.Successor = this;
                MagicBit = pred.MagicBit;
            }
            else
            {
                zBounds = new ZingerBounds();
                MagicBit = false;
                CurrentDepth = 0;
                if (ZingerConfiguration.DoDelayBounding)
                {
                    ZingDBSchedState = s.ZingDBSchedState.Clone(false);
                    ZingDBScheduler = s.ZingDBScheduler;
                }
                else if (ZingerConfiguration.DoPreemptionBounding)
                {
                    preemptionBounding = new ZingPreemptionBounding(ProcessInfo, NumProcesses, 0);
                }
                if (ZingerConfiguration.DronacharyaEnabled || ZingerConfiguration.IsPluginEnabled)
                {
                    ZingerPlugin = s.ZingerPlugin;
                    ZingerPluginState = s.ZingerPluginState.Clone();
                }
            }
        }