public void TestFeeback()
        {
            var bursts1 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 2, IoBurstTime = 3
                }, new BurstCycle {
                    CpuBurstTime = 4, IoBurstTime = 6
                }
            };
            var bursts2 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 4, IoBurstTime = 6
                }, new BurstCycle {
                    CpuBurstTime = 7, IoBurstTime = 0
                }
            };
            var bursts3 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 5, IoBurstTime = 4
                }, new BurstCycle {
                    CpuBurstTime = 8, IoBurstTime = 0
                }
            };
            var process1 = new Process(bursts1)
            {
                Id = 0, ArrivalTime = 0
            };
            var process2 = new Process(bursts2)
            {
                Id = 1, ArrivalTime = 3
            };
            var process3 = new Process(bursts3)
            {
                Id = 2, ArrivalTime = 10
            };

            var processLoad = new ProcessLoad
            {
                Processes = new List <Process>
                {
                    process1,
                    process2,
                    process3,
                }
            };

            var scheduler = new Feedback(processLoad);
            var io        = new Io();
            var cpu       = new Cpu();
            var result    = this.ProcessDispatcher.Start(scheduler, cpu, io);
            //var debugOutput = new DebugOutput();
            //debugOutput.PrintHistory(cpu.History, io.History);
            var consoleOutput = new ConsoleOutput();

            consoleOutput.PrintHistory(cpu.History, io.History);
        }
        public void TestFirstComeFirstServed()
        {
            var bursts1 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 10, IoBurstTime = 15
                }, new BurstCycle {
                    CpuBurstTime = 4, IoBurstTime = 6
                }
            };
            var bursts2 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 8, IoBurstTime = 6
                }, new BurstCycle {
                    CpuBurstTime = 7, IoBurstTime = 0
                }
            };
            var bursts3 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 15, IoBurstTime = 4
                }, new BurstCycle {
                    CpuBurstTime = 8, IoBurstTime = 0
                }
            };
            var process1 = new Process(bursts1)
            {
                Id = 0, ArrivalTime = 0
            };
            var process2 = new Process(bursts2)
            {
                Id = 1, ArrivalTime = 3
            };
            var process3 = new Process(bursts3)
            {
                Id = 2, ArrivalTime = 10
            };

            var processLoad = new ProcessLoad
            {
                Processes = new List <Process>
                {
                    process1,
                    process2,
                    process3,
                }
            };

            var scheduler = new FirstComeFirstServed(processLoad);
            var io        = new Io();
            var cpu       = new Cpu();

            var result     = this.ProcessDispatcher.Start(scheduler, cpu, io);
            var cpuHistory = cpu.History;
            var ioHistory  = io.History;
        }
        public void TestRoundRobin()
        {
            var bursts1 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 10, IoBurstTime = 15
                }, new BurstCycle {
                    CpuBurstTime = 4, IoBurstTime = 6
                }
            };
            var bursts2 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 8, IoBurstTime = 6
                }, new BurstCycle {
                    CpuBurstTime = 7, IoBurstTime = 0
                }
            };
            var bursts3 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 15, IoBurstTime = 4
                }, new BurstCycle {
                    CpuBurstTime = 8, IoBurstTime = 0
                }
            };
            var process1 = new Process(bursts1)
            {
                ArrivalTime = 0
            };
            var process2 = new Process(bursts2)
            {
                ArrivalTime = 3
            };
            var process3 = new Process(bursts3)
            {
                ArrivalTime = 10
            };

            var processLoad = new ProcessLoad
            {
                Processes = new List <Process>
                {
                    process1,
                    process2,
                    process3,
                }
            };

            var scheduler = new RoundRobin(processLoad, 4);
            var io        = new Io();
            var cpu       = new Cpu();

            var result = this.ProcessDispatcher.Start(scheduler, cpu, io);
        }
        public void TestShortestRemainingTimeFirst()
        {
            var bursts1 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 2, IoBurstTime = 3
                }, new BurstCycle {
                    CpuBurstTime = 4, IoBurstTime = 6
                }
            };
            var bursts2 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 4, IoBurstTime = 6
                }, new BurstCycle {
                    CpuBurstTime = 7, IoBurstTime = 0
                }
            };
            var bursts3 = new List <BurstCycle> {
                new BurstCycle {
                    CpuBurstTime = 5, IoBurstTime = 4
                }, new BurstCycle {
                    CpuBurstTime = 8, IoBurstTime = 0
                }
            };
            var process1 = new Process(bursts1)
            {
                ArrivalTime = 0
            };
            var process2 = new Process(bursts2)
            {
                ArrivalTime = 3
            };
            var process3 = new Process(bursts3)
            {
                ArrivalTime = 10
            };

            var processLoad = new ProcessLoad
            {
                Processes = new List <Process>
                {
                    process1,
                    process2,
                    process3,
                }
            };

            var scheduler = new ShortestRemainingTime(processLoad);
            var io        = new Io();
            var cpu       = new Cpu();

            var result = this.ProcessDispatcher.Start(scheduler, cpu, io);
        }
Exemple #5
0
        private ProcessLoad AdjustLoad(ProcessLoad processLoad)
        {
            if (processLoad.Name == "Streamster.ClientApp.Win")
            {
                processLoad.Name = "Streamster";
            }

            if (processLoad.Load > 99)
            {
                processLoad.Load = 99;
            }
            return(processLoad);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(150, 50);
            Console.WriteLine("Enter number of processes to simulate...");
            var totalProcesses                   = Convert.ToInt32(Console.ReadLine());
            var processLoad                      = ProcessLoad.Create(totalProcesses);
            var feedbackProcessLoad              = processLoad.DeepCopy();
            var firstComeFirstServedProcessLoad  = processLoad.DeepCopy();
            var roundRobinProcessLoad            = processLoad.DeepCopy();
            var shortestProcessTimeProcessLoad   = processLoad.DeepCopy();
            var shortestRemainingTimeProcessLoad = processLoad.DeepCopy();

            var runtime    = 9;
            var schedulers = new List <Scheduler>
            {
                new Feedback(feedbackProcessLoad),
                new FirstComeFirstServed(firstComeFirstServedProcessLoad),
                new RoundRobin(roundRobinProcessLoad, runtime),
                new ShortestProcessTime(shortestProcessTimeProcessLoad),
                new ShortestRemainingTime(shortestRemainingTimeProcessLoad),
            };

            var processDispatcher = new ProcessDispatcher();
            var consoleOutput     = new ConsoleOutput();
            var stringBuilder     = new StringBuilder();

            foreach (var scheduler in schedulers)
            {
                var cpu = new Cpu();
                var io  = new Io();
                processDispatcher.Start(scheduler, cpu, io);
                var summary = scheduler.ProcessLoad.SummarizeOutput(cpu, io);
                stringBuilder.AppendLine(string.Format("Average Turnaround: {0}", summary.AverageTurnaroundTime));
                stringBuilder.AppendLine(string.Format("Average Wait: {0}", summary.AverageWaitTime));
                stringBuilder.AppendLine(string.Format("Cpu Utilization: {0}", summary.CpuUtilization));
                Console.WriteLine("Average Turnaround: {0}", summary.AverageTurnaroundTime);
                Console.WriteLine("Average Wait: {0}", summary.AverageWaitTime);
                Console.WriteLine("Cpu Utilization: {0}", summary.CpuUtilization);
                consoleOutput.PrintHistory(cpu.History, io.History);
                consoleOutput.PrintHistoryToStringBuilder(cpu.History, io.History, stringBuilder);
            }

            using (TextWriter writer = File.CreateText(@"c:\temp\output.txt"))
            {
                writer.Write(stringBuilder.ToString());
            }
        }
Exemple #7
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            int            numprocs = Convert.ToInt32(txtNumOfProcs.Text);
            var            userin   = new UserInput();
            List <Process> lp       = userin.makeProcesses(numprocs);

            var processLoad = new ProcessLoad
            {
                Processes = userin.makeProcesses(numprocs),
            };

            int last     = numprocs + 1;
            int arraycpu = 0;
            int arrayio  = 0;

            int time2 = 0;


            var scheduler = new FirstComeFirstServed(processLoad);
            var io        = new Io();
            var cpu       = new Cpu();

            ProcessDispatcher = new ProcessDispatcher();

            var result     = this.ProcessDispatcher.Start(scheduler, cpu, io);
            var cpuHistory = cpu.History;
            var ioHistory  = io.History;

            var consoleOutput = new ConsoleOutput();

            consoleOutput.PrintHistory(cpuHistory, ioHistory);

            double cpuutil = Convert.ToDouble(arraycpu) / Convert.ToDouble(time2) * 100.0;
            Int32  total   = Convert.ToInt32(cpuutil);

            pfcfs.Value = total;

            int waittime = (time2 - arrayio) / numprocs;

            lfcfswait.Content = waittime;
        }