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()); } }
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; }
public void TestInitialize() { this.ProcessDispatcher = new ProcessDispatcher(); }