Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Src/PChecker/CheckerCore/Actors/Events/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ namespace PChecker.Actors.Events
[DataContract]
public abstract class Event
{
public int Loc { get; set; }
}
}
30 changes: 15 additions & 15 deletions Src/PChecker/CheckerCore/Actors/Logging/JsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace PChecker.Actors.Logging
/// <summary>
/// Class for handling generating the vector clock for a log entry
/// </summary>
internal class VectorClockGenerator
public class VectorClockGenerator
{
/// <summary>
/// Nested class for handling FIFO send receive requests.
Expand Down Expand Up @@ -61,7 +61,7 @@ internal FifoSendReceiveMapping()
/// <summary>
/// Field declaration that keeps track of a global vector clock map of all the machines.
/// </summary>
private readonly Dictionary<string, Dictionary<string, int>> _contextVcMap;
public readonly Dictionary<string, Dictionary<string, int>> ContextVcMap;

/// <summary>
/// Field declaration that keeps track of unprocessed send requests. I.e., when a send request happened
Expand All @@ -85,7 +85,7 @@ internal FifoSendReceiveMapping()
/// </summary>
public VectorClockGenerator()
{
_contextVcMap = new Dictionary<string, Dictionary<string, int>>();
ContextVcMap = new Dictionary<string, Dictionary<string, int>>();
_unhandledSendRequests = new Dictionary<string, Dictionary<string, int>>();
_machines = new HashSet<string>();
_sendRequestsCount = new Dictionary<string, FifoSendReceiveMapping>();
Expand Down Expand Up @@ -205,25 +205,25 @@ private void updateMachineVcMap(string machine, Dictionary<string, int> senderVc
{
// Get a set of all machine names to update between the sender vc map and the current machine vc map (minus the current machine)
var machinesToUpdateInVc =
new HashSet<string>(_contextVcMap[machine].Keys.Union(senderVcMap.Keys).Except(new[] { machine }));
new HashSet<string>(ContextVcMap[machine].Keys.Union(senderVcMap.Keys).Except(new[] { machine }));

// Update local machine's vector clock in _contextVcMap, outside of itself, since it was already updated (incremented) from above
// right before the switch case.
// The rule for the remaining machines to be updated is taking the max between the sender machine's vector clock at that time and
// the current machine's vector clock. Details can be found here: https://en.wikipedia.org/wiki/Vector_clock
foreach (var machineToUpdate in machinesToUpdateInVc)
{
if (_contextVcMap[machine].TryGetValue(machineToUpdate, out var localMachineToUpdateValue))
if (ContextVcMap[machine].TryGetValue(machineToUpdate, out var localMachineToUpdateValue))
{
if (senderVcMap.TryGetValue(machineToUpdate, out var senderMachineToUpdateValue))
{
_contextVcMap[machine][machineToUpdate] =
ContextVcMap[machine][machineToUpdate] =
Math.Max(senderMachineToUpdateValue, localMachineToUpdateValue);
}
}
else
{
_contextVcMap[machine].Add(machineToUpdate, senderVcMap[machineToUpdate]);
ContextVcMap[machine].Add(machineToUpdate, senderVcMap[machineToUpdate]);
}
}
}
Expand All @@ -243,11 +243,11 @@ public void HandleLogEntry(LogEntry logEntry)
if (MachineIsNew(machine))
{
_machines.Add(machine);
_contextVcMap.Add(machine, new Dictionary<string, int> { { machine, 0 } });
ContextVcMap.Add(machine, new Dictionary<string, int> { { machine, 0 } });
}

// Always update the local machine count by one on any event.
_contextVcMap[machine][machine] += 1;
ContextVcMap[machine][machine] += 1;

switch (logType)
{
Expand All @@ -273,13 +273,13 @@ public void HandleLogEntry(LogEntry logEntry)
// Update the sendReqId with the send count of it.
sendReqId += $":_{_sendRequestsCount[hashedGeneralSendReqId].SentCount}";
var hashedSendReqId = HashString(sendReqId);
_unhandledSendRequests.Add(hashedSendReqId, CopyVcMap(_contextVcMap[machine]));
_unhandledSendRequests.Add(hashedSendReqId, CopyVcMap(ContextVcMap[machine]));
break;

// For MonitorProcessEvents, tie it to the senderMachine's current vector clock
// so that there is some association in the timeline
case "MonitorProcessEvent":
if (logDetails.Sender != null) updateMachineVcMap(machine, _contextVcMap[logDetails.Sender]);
if (logDetails.Sender != null) updateMachineVcMap(machine, ContextVcMap[logDetails.Sender]);
break;

// On dequeue OR receive event, has the string containing information about the current machine that dequeued (i.e. received the event),
Expand Down Expand Up @@ -317,7 +317,7 @@ public void HandleLogEntry(LogEntry logEntry)
}

// Update the log entry with the vector clock.
logEntry.Details.Clock = CopyVcMap(_contextVcMap[machine]);
logEntry.Details.Clock = CopyVcMap(ContextVcMap[machine]);
}
}

Expand Down Expand Up @@ -533,7 +533,7 @@ public class JsonWriter
/// <summary>
/// Vector clock generator instance to help with vector clock generation.
/// </summary>
private readonly VectorClockGenerator _vcGenerator;
internal VectorClockGenerator VcGenerator {get;}

/// <summary>
/// Getter for accessing log entry details.
Expand All @@ -552,7 +552,7 @@ public JsonWriter()
{
_logs = new List<LogEntry>();
_log = new LogEntry();
_vcGenerator = new VectorClockGenerator();
VcGenerator = new VectorClockGenerator();
}

/// <summary>
Expand Down Expand Up @@ -716,7 +716,7 @@ public void AddToLogs(bool updateVcMap = false)
{
if (updateVcMap)
{
_vcGenerator.HandleLogEntry(_log);
VcGenerator.HandleLogEntry(_log);
}

_logs.Add(_log);
Expand Down
51 changes: 50 additions & 1 deletion Src/PChecker/CheckerCore/CheckerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ public int MaxSchedulingSteps
[DataMember]
public uint TestingProcessId;

/// <summary>
/// The source of the pattern generator.
/// </summary>
[DataMember]
public string PatternSource;

/// <summary>
/// Additional assembly specifications to instrument for code coverage, besides those in the
/// dependency graph between <see cref="AssemblyToBeAnalyzed"/> and the Microsoft.Coyote DLLs.
Expand Down Expand Up @@ -286,6 +292,42 @@ public int MaxSchedulingSteps
[DataMember]
public string JvmArgs;

/// <summary>
/// For feedback strategy, save input if the pattern are partially matched.
/// </summary>
[DataMember]
public bool SavePartialMatch;

/// <summary>
/// For feedback strategy, discard saved generators if the size of the buffer is greater than N.
/// </summary>
[DataMember]
public int DiscardAfter;

/// <summary>
/// For feedback strategy, schedule generator mutations based on diversity.
/// </summary>
[DataMember]
public bool DiversityBasedPriority;

/// <summary>
/// For feedback strategy, ignore the pattern feedback.
/// </summary>
[DataMember]
public bool IgnorePatternFeedback;

/// <summary>
/// For feedback strategy, use priority based sampling.
/// </summary>
[DataMember]
public bool PriorityBasedSampling;

/// <summary>
/// Enable conflict analysis for scheduling optimization.
/// </summary>
[DataMember]
public bool EnableConflictAnalysis;

/// <summary>
/// Initializes a new instance of the <see cref="CheckerConfiguration"/> class.
/// </summary>
Expand All @@ -307,7 +349,7 @@ protected CheckerConfiguration()
RandomGeneratorSeed = null;
IncrementalSchedulingSeed = false;
PerformFullExploration = false;
MaxFairSchedulingSteps = 100000; // 10 times the unfair steps
MaxFairSchedulingSteps = 10000; // 10 times the unfair steps
MaxUnfairSchedulingSteps = 10000;
UserExplicitlySetMaxFairSchedulingSteps = false;
TestingProcessId = 0;
Expand All @@ -331,9 +373,16 @@ protected CheckerConfiguration()

EnableColoredConsoleOutput = false;
DisableEnvironmentExit = true;
SavePartialMatch = true;
DiscardAfter = 100;
DiversityBasedPriority = true;
IgnorePatternFeedback = false;
PriorityBasedSampling = true;
EnableConflictAnalysis = false;

PSymArgs = "";
JvmArgs = "";
PatternSource = "";
}

/// <summary>
Expand Down
22 changes: 22 additions & 0 deletions Src/PChecker/CheckerCore/Pattern/EventObj.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using PChecker.Actors.Events;
using PChecker.Specifications.Monitors;

namespace PChecker.Matcher;

public class EventObj
{
public Event Event;
public string? Sender;
public string? Receiver;
public string State;
public int Index;

public EventObj(Event e, string? sender, string? receiver, string state, int index)
{
Event = e;
Sender = sender;
Receiver = receiver;
State = state;
Index = index;
}
}
Loading