Beispiel #1
0
        /// <summary>
        /// Checks liveness at a trace cycle.
        /// </summary>
        /// <param name="root">Cycle start</param>
        internal void CheckLivenessAtTraceCycle(Fingerprint root, Trace trace)
        {
            var cycle = new List<TraceStep>();

            do
            {
                Output.Debug(DebugType.Liveness, "<LivenessDebug> Cycle contains {0}.",
                    trace.Peek().Fingerprint.ToString());
                cycle.Add(trace.Pop());
            }
            while (trace.Peek() != null && !trace.Peek().Fingerprint.Equals(root));

            if (!this.IsSchedulingFair(cycle))
            {
                Output.Debug(DebugType.Liveness, "<LivenessDebug> Scheduling in cycle is unfair.");
                return;
            }
            else if (!this.IsNondeterminismFair(cycle))
            {
                Output.Debug(DebugType.Liveness, "<LivenessDebug> Nondeterminism in cycle is unfair.");
                return;
            }

            Output.Debug(DebugType.Liveness, "<LivenessDebug> Cycle execution is fair.");

            var hotMonitors = this.GetHotMonitors(cycle);
            foreach (var monitor in hotMonitors)
            {
                string message = Output.Format("Monitor '{0}' detected infinite execution that " +
                    "violates a liveness property.", monitor.GetType().Name);
                PSharpRuntime.BugFinder.NotifyAssertionFailure(message, false);
            }

            PSharpRuntime.BugFinder.Stop();
        }
Beispiel #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="fingerprint">Fingerprint</param>
 /// <param name="enabledMachines">Enabled machines</param>
 /// <param name="monitorStatus">Monitor status</param>
 internal State(Fingerprint fingerprint, HashSet<BaseMachine> enabledMachines,
     Dictionary<Monitor, MonitorStatus> monitorStatus)
 {
     this.Fingerprint = fingerprint;
     this.EnabledMachines = enabledMachines;
     this.MonitorStatus = monitorStatus;
 }
        /// <summary>
        /// Checks liveness at a trace cycle.
        /// </summary>
        /// <param name="root">Cycle start</param>
        /// <param name="stateMap">Map of states</param>
        internal void CheckLivenessAtTraceCycle(Fingerprint root, Dictionary<TraceStep, State> stateMap)
        {
            var cycle = new Dictionary<TraceStep, State>();

            do
            {
                var traceStep = PSharpRuntime.ProgramTrace.Pop();
                var state = stateMap[traceStep];
                cycle.Add(traceStep, state);

                Output.Debug("<LivenessDebug> Cycle contains {0} with {1}.",
                    traceStep.Type, state.Fingerprint.ToString());

                // The state can be safely removed, because the liveness detection
                // algorithm currently removes cycles, so a specific state can only
                // appear once in the trace.
                stateMap.Remove(traceStep);
            }
            while (PSharpRuntime.ProgramTrace.Peek() != null && !stateMap[
                PSharpRuntime.ProgramTrace.Peek()].Fingerprint.Equals(root));

            if (!this.IsSchedulingFair(cycle))
            {
                Output.Debug("<LivenessDebug> Scheduling in cycle is unfair.");
                return;
            }
            else if (!this.IsNondeterminismFair(cycle))
            {
                Output.Debug("<LivenessDebug> Nondeterminism in cycle is unfair.");
                return;
            }

            Output.Debug("<LivenessDebug> Cycle execution is fair.");

            var hotMonitors = this.GetHotMonitors(cycle);
            foreach (var monitor in hotMonitors)
            {
                string message = Output.Format("Monitor '{0}' detected infinite execution that " +
                    "violates a liveness property.", monitor.GetType().Name);
                PSharpRuntime.BugFinder.NotifyAssertionFailure(message, false);
            }

            if (PSharpRuntime.Configuration.DepthBound == 0 || hotMonitors.Count > 0)
            {
                PSharpRuntime.BugFinder.Stop();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Creates a scheduling choice trace step.
        /// </summary>
        /// <param name="fingerprint">Fingerprint</param>
        /// <param name="scheduledMachine">Scheduled machine</param>
        /// <param name="enabledMachines">Enabled machines</param>
        /// <param name="monitorStatus">Monitor status</param>
        /// <returns>TraceStep</returns>
        internal static TraceStep CreateSchedulingChoice(Fingerprint fingerprint, Machine scheduledMachine,
            HashSet<Machine> enabledMachines, Dictionary<Monitor, MonitorStatus> monitorStatus)
        {
            var traceStep = new TraceStep();

            traceStep.IsChoice = false;
            traceStep.Fingerprint = fingerprint;

            traceStep.ScheduledMachine = scheduledMachine;
            traceStep.EnabledMachines = enabledMachines;
            traceStep.MonitorStatus = monitorStatus;

            traceStep.Previous = null;
            traceStep.Next = null;

            return traceStep;
        }
Beispiel #5
0
        /// <summary>
        /// Creates a nondeterministic choice trace step.
        /// </summary>
        /// <param name="fingerprint">Fingerprint</param>
        /// <param name="uniqueId">Unique nondet id</param>
        /// <param name="choice">Choice</param>
        /// <param name="enabledMachines">Enabled machines</param>
        /// <param name="monitorStatus">Monitor status</param>
        /// <returns>TraceStep</returns>
        internal static TraceStep CreateNondeterministicChoice(Fingerprint fingerprint,
            string uniqueId, bool choice, HashSet<Machine> enabledMachines,
            Dictionary<Monitor, MonitorStatus> monitorStatus)
        {
            var traceStep = new TraceStep();

            traceStep.IsChoice = true;
            traceStep.Fingerprint = fingerprint;

            traceStep.NondetId = uniqueId;
            traceStep.Choice = choice;
            traceStep.EnabledMachines = enabledMachines;
            traceStep.MonitorStatus = monitorStatus;

            traceStep.Previous = null;
            traceStep.Next = null;

            return traceStep;
        }