Example #1
0
        private void SynchronousChannelInputOutput(List <Configuration> returnList, int i, Valuation GlobalEnv, string evt)
        {
            List <ConfigurationWithChannelData> outputs = new List <ConfigurationWithChannelData>();

            Processes[i].SyncOutput(GlobalEnv, outputs);

            foreach (ConfigurationWithChannelData vm in outputs)
            {
                if (evt != null && vm.Event != evt)
                {
                    continue;
                }

                Process output = vm.Process;

                for (int k = 0; k < Processes.Count; k++)
                {
                    if (k != i)
                    {
                        List <Configuration> syncedProcess = new List <Configuration>();
                        Processes[k].SyncInput(vm, syncedProcess);

                        foreach (Configuration p in syncedProcess)
                        {
                            List <Process> newProcess = new List <Process>(Processes.Count);
                            newProcess.AddRange(Processes);
                            newProcess[i] = output;
                            newProcess[k] = p.Process;

                            IndexParallel interleave = new IndexParallel(newProcess, Alphabets);
                            Configuration newStep    = new Configuration(interleave, vm.Event, vm.DisplayName, GlobalEnv, false);
                            newStep.IsAtomic = vm.IsAtomic || p.IsAtomic;

                            if (AssertionBase.CalculateParticipatingProcess)
                            {
                                newStep.ParticipatingProcesses = new string[] { i.ToString(), k.ToString() };
                            }

                            returnList.Add(newStep);
                        }
                    }
                }
            }
        }
Example #2
0
        private void SynchronousChannelInputOutput(List<Configuration> returnList, int i, Valuation GlobalEnv, string evt)
        {
            List<ConfigurationWithChannelData> outputs = new List<ConfigurationWithChannelData>();
                Processes[i].SyncOutput(GlobalEnv,outputs);

            foreach (ConfigurationWithChannelData vm in outputs)
            {
                if(evt != null && vm.Event != evt)
                {
                    continue;
                }

                Process output = vm.Process;

                for (int k = 0; k < Processes.Count; k++)
                {
                    if (k != i)
                    {
                        List<Configuration> syncedProcess = new List<Configuration>();
                        Processes[k].SyncInput(vm, syncedProcess);

                        foreach (Configuration p in syncedProcess)
                        {
                            List<Process> newProcess = new List<Process>(Processes.Count);
                            newProcess.AddRange(Processes);
                            newProcess[i] = output;
                            newProcess[k] = p.Process;

                            IndexParallel interleave = new IndexParallel(newProcess, Alphabets);
                            Configuration newStep = new Configuration(interleave, vm.Event, vm.DisplayName, GlobalEnv, false);
                            newStep.IsAtomic = vm.IsAtomic || p.IsAtomic;

                            if (AssertionBase.CalculateParticipatingProcess)
                            {
                                newStep.ParticipatingProcesses = new string[]{i.ToString(), k.ToString()};
                            }

                            returnList.Add(newStep);
                        }
                    }
                }
            }
        }
Example #3
0
        public override void MoveOneStep(Valuation GlobalEnv, List<Configuration> list)
        {
            if (Alphabets == null)
            {
                IdentifySharedEventsAndVariables();
            }

            List<string> barrierEnabledEvents = new List<string>();
            List<string> disabled = new List<string>();

            System.Diagnostics.Debug.Assert(list.Count == 0);

            Dictionary<string, List<Configuration>> syncSteps = new Dictionary<string, List<Configuration>>();
            for (int i = 0; i < Processes.Count; i++)
            {
                //Process process = Processes[i];
                List<Configuration> list1 = new List<Configuration>();
                Processes[i].MoveOneStep(GlobalEnv, list1);

                List<string> enabled = new List<string>(list1.Count);

                for (int j = 0; j < list1.Count; j++)
                {
                    Configuration step = list1[j];

                    string evt = step.Event;

                    //if it happens that a data operation shares the same name with the sync event, treat it as an interleave case
                    if (!Alphabets[i].Contains(evt) || step.IsDataOperation)
                    {
                        if (AssertionBase.CalculateParticipatingProcess)
                        {
                            step.ParticipatingProcesses = new string[] { i.ToString() };
                        }

                        List<Process> newProcess = new List<Process>(Processes.Count);
                        newProcess.AddRange(Processes);
                        newProcess[i] = step.Process;

                        step.Process = new IndexParallel(newProcess, Alphabets);
                        list.Add(step);
                    }
                    else
                    {
                        enabled.Add(evt);
                        string key = evt + Constants.SEPARATOR + i;

                        if (!syncSteps.ContainsKey(key))
                        {
                            syncSteps.Add(key, new List<Configuration>());
                        }

                        syncSteps[key].Add(step);

                        if (!barrierEnabledEvents.Contains(evt)) //Alphabets[i].Contains(evt) &&
                        {
                            barrierEnabledEvents.Add(evt);
                        }
                    }
                }

                //int alphabetsCount = Alphabets[i].Count;
                foreach (string s in Alphabets[i])
                {
                    if (!enabled.Contains(s) && !disabled.Contains(s))
                    {
                        disabled.Add(s);
                    }
                }

                //to check whether there are synchoronous channel input/output
                if (Specification.HasSyncrhonousChannel)
                {
                    SynchronousChannelInputOutput(list, i, GlobalEnv, null);
                }
            }

            int disabledCount = disabled.Count;
            for (int i = 0; i < disabledCount; i++)
            {
                barrierEnabledEvents.Remove(disabled[i]);
            }

            List<bool> isAtomic = null;

            //move the barrier synchronization events.
            foreach (string evt in barrierEnabledEvents)
            {
                //maps an event to the list of resulting processes.
                List<List<Process>> moves = new List<List<Process>>();
                moves.Add(new List<Process>());

                if (SpecificationBase.HasAtomicEvent)
                {
                    isAtomic = new List<bool>();
                    isAtomic.Add(false);
                }

                List<string> participatingProcesses = new List<string>();

                for (int i = 0; i < Processes.Count; i++)
                {
                    if (Alphabets[i].Contains(evt))
                    {
                        participatingProcesses.Add(i.ToString());

                        List<Configuration> steps = syncSteps[evt + Constants.SEPARATOR + i]; //Processes[i].MoveOneStep(eStep, evt);

                        List<List<Process>> toAdd = new List<List<Process>>(moves.Count);

                        foreach (Configuration step in steps)
                        {
                            //if it happens that a data operation shares the same name with the sync event, ignore
                            if (!step.IsDataOperation)
                            {
                                if (moves[0].Count == i)
                                {
                                    foreach (List<Process> list2 in moves)
                                    {
                                        list2.Add(step.Process);
                                        if (step.IsAtomic)
                                        {
                                            for (int j = 0; j < isAtomic.Count; j++)
                                            {
                                                isAtomic[j] = true;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    //If there non-determinism, clone and then add.

                                    for (int k = 0; k < moves.Count; k++)
                                    {
                                        List<Process> list2 = moves[k];

                                        List<Process> newProcList = new List<Process>();

                                        for (int j = 0; j < list2.Count - 1; j++)
                                        {
                                            newProcList.Add(list2[j]);
                                        }

                                        newProcList.Add(step.Process);
                                        toAdd.Add(newProcList);

                                        if (SpecificationBase.HasAtomicEvent)
                                        {
                                            if (!isAtomic[k])
                                            {
                                                isAtomic.Add(step.IsAtomic);
                                            }
                                            else
                                            {
                                                isAtomic.Add(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        moves.AddRange(toAdd);
                    }
                    else
                    {
                        foreach (List<Process> move in moves)
                        {
                            move.Add(Processes[i]);
                        }
                    }
                }

                for (int i = 0; i < moves.Count; i++)
                {
                    List<Process> list2 = moves[i];
                    IndexParallel para = new IndexParallel(list2, Alphabets);

                    Configuration tmpStep = new Configuration(para, evt, null, GlobalEnv, false);

                    if (SpecificationBase.HasAtomicEvent)
                    {
                        tmpStep.IsAtomic = isAtomic[i];
                    }

                    if (AssertionBase.CalculateParticipatingProcess)
                    {
                        tmpStep.ParticipatingProcesses = participatingProcesses.ToArray();
                    }

                    list.Add(tmpStep);
                }
            }

            //return returnList;
        }
Example #4
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            if (Alphabets == null)
            {
                IdentifySharedEventsAndVariables();
            }

            List <string> barrierEnabledEvents = new List <string>();
            List <string> disabled             = new List <string>();

            System.Diagnostics.Debug.Assert(list.Count == 0);

            Dictionary <string, List <Configuration> > syncSteps = new Dictionary <string, List <Configuration> >();

            for (int i = 0; i < Processes.Count; i++)
            {
                //Process process = Processes[i];
                List <Configuration> list1 = new List <Configuration>();
                Processes[i].MoveOneStep(GlobalEnv, list1);

                List <string> enabled = new List <string>(list1.Count);

                for (int j = 0; j < list1.Count; j++)
                {
                    Configuration step = list1[j];

                    string evt = step.Event;


                    //if it happens that a data operation shares the same name with the sync event, treat it as an interleave case
                    if (!Alphabets[i].Contains(evt) || step.IsDataOperation)
                    {
                        if (AssertionBase.CalculateParticipatingProcess)
                        {
                            step.ParticipatingProcesses = new string[] { i.ToString() };
                        }

                        List <Process> newProcess = new List <Process>(Processes.Count);
                        newProcess.AddRange(Processes);
                        newProcess[i] = step.Process;

                        step.Process = new IndexParallel(newProcess, Alphabets);
                        list.Add(step);
                    }
                    else
                    {
                        enabled.Add(evt);
                        string key = evt + Constants.SEPARATOR + i;

                        if (!syncSteps.ContainsKey(key))
                        {
                            syncSteps.Add(key, new List <Configuration>());
                        }

                        syncSteps[key].Add(step);

                        if (!barrierEnabledEvents.Contains(evt)) //Alphabets[i].Contains(evt) &&
                        {
                            barrierEnabledEvents.Add(evt);
                        }
                    }
                }

                //int alphabetsCount = Alphabets[i].Count;
                foreach (string s in Alphabets[i])
                {
                    if (!enabled.Contains(s) && !disabled.Contains(s))
                    {
                        disabled.Add(s);
                    }
                }

                //to check whether there are synchoronous channel input/output
                if (Specification.HasSyncrhonousChannel)
                {
                    SynchronousChannelInputOutput(list, i, GlobalEnv, null);
                }
            }

            int disabledCount = disabled.Count;

            for (int i = 0; i < disabledCount; i++)
            {
                barrierEnabledEvents.Remove(disabled[i]);
            }

            List <bool> isAtomic = null;

            //move the barrier synchronization events.
            foreach (string evt in barrierEnabledEvents)
            {
                //maps an event to the list of resulting processes.
                List <List <Process> > moves = new List <List <Process> >();
                moves.Add(new List <Process>());

                if (SpecificationBase.HasAtomicEvent)
                {
                    isAtomic = new List <bool>();
                    isAtomic.Add(false);
                }

                List <string> participatingProcesses = new List <string>();

                for (int i = 0; i < Processes.Count; i++)
                {
                    if (Alphabets[i].Contains(evt))
                    {
                        participatingProcesses.Add(i.ToString());

                        List <Configuration> steps = syncSteps[evt + Constants.SEPARATOR + i]; //Processes[i].MoveOneStep(eStep, evt);

                        List <List <Process> > toAdd = new List <List <Process> >(moves.Count);

                        foreach (Configuration step in steps)
                        {
                            //if it happens that a data operation shares the same name with the sync event, ignore
                            if (!step.IsDataOperation)
                            {
                                if (moves[0].Count == i)
                                {
                                    foreach (List <Process> list2 in moves)
                                    {
                                        list2.Add(step.Process);
                                        if (step.IsAtomic)
                                        {
                                            for (int j = 0; j < isAtomic.Count; j++)
                                            {
                                                isAtomic[j] = true;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    //If there non-determinism, clone and then add.

                                    for (int k = 0; k < moves.Count; k++)
                                    {
                                        List <Process> list2 = moves[k];

                                        List <Process> newProcList = new List <Process>();

                                        for (int j = 0; j < list2.Count - 1; j++)
                                        {
                                            newProcList.Add(list2[j]);
                                        }

                                        newProcList.Add(step.Process);
                                        toAdd.Add(newProcList);


                                        if (SpecificationBase.HasAtomicEvent)
                                        {
                                            if (!isAtomic[k])
                                            {
                                                isAtomic.Add(step.IsAtomic);
                                            }
                                            else
                                            {
                                                isAtomic.Add(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        moves.AddRange(toAdd);
                    }
                    else
                    {
                        foreach (List <Process> move in moves)
                        {
                            move.Add(Processes[i]);
                        }
                    }
                }

                for (int i = 0; i < moves.Count; i++)
                {
                    List <Process> list2 = moves[i];
                    IndexParallel  para  = new IndexParallel(list2, Alphabets);

                    Configuration tmpStep = new Configuration(para, evt, null, GlobalEnv, false);

                    if (SpecificationBase.HasAtomicEvent)
                    {
                        tmpStep.IsAtomic = isAtomic[i];
                    }

                    if (AssertionBase.CalculateParticipatingProcess)
                    {
                        tmpStep.ParticipatingProcesses = participatingProcesses.ToArray();
                    }

                    list.Add(tmpStep);
                }
            }

            //return returnList;
        }