示例#1
0
        public void RegisterCreateMachine(MachineId source, MachineId target)
        {
            LogCreate(source, target);
            CreateCount++;

            // The id of the created machine should not conflict with an id seen earlier
            Runtime.Assert(MS.ContainsKey(target.Value) == false, $"New ID {target} conflicts with an already existing id");

            DescriptiveName[target.Value] = target.ToString();

            // In case the runtime creates a machine, simply create a machine state for it,
            // with a fresh VC where the appropriate component is incremented.
            // no hb rule needs to be triggered
            if (source == null)
            {
                var newState = new InstrMachineState(target.Value, this.Log, Config.EnableRaceDetectorLogging);
                MS[target.Value] = newState;
                return;
            }

            DescriptiveName[source.Value] = source.ToString();

            var sourceMachineState = GetCurrentState(source);
            var targetState        = new InstrMachineState(target.Value, this.Log, Config.EnableRaceDetectorLogging);

            targetState.JoinEpochAndVC(sourceMachineState.VC);
            MS[target.Value] = targetState;
            sourceMachineState.IncrementEpochAndVC();
        }