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; }
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 TestConcurrentProcess() { var s = new FirstComeFirstServed(); var processes = ConcurrentProcess.Processes; var expected = new[] { new ProcessControlBlock { Process = processes[0], DispatchTime = 0, BurstTime = 7, RemainingBurstTime = 0, ResponseTime = 0 - 0, WaitingTime = 0 - 0, }, new ProcessControlBlock { Process = processes[1], DispatchTime = 0 + 7, BurstTime = 3, RemainingBurstTime = 0, ResponseTime = 0 + 7 - 0, WaitingTime = 0 + 7 - 0, }, new ProcessControlBlock { Process = processes[2], DispatchTime = 0 + 7 + 3, BurstTime = 1, RemainingBurstTime = 0, ResponseTime = 0 + 7 + 3 - 2, WaitingTime = 0 + 7 + 3 - 2, }, new ProcessControlBlock { Process = processes[3], DispatchTime = 0 + 7 + 3 + 1, BurstTime = 7, RemainingBurstTime = 0, ResponseTime = 0 + 7 + 3 + 1 - 4, WaitingTime = 0 + 7 + 3 + 1 - 4, }, }; foreach (var p in processes) { s.Push(p); } var result = s.GetResult(); Assert.AreEqual(expected.Length, result.Count, "프로세스 처리 불충분"); for (var i = 0; i < expected.Length; i++) { var e = expected[i]; var r = result[i]; Assert.AreEqual(e.Process.ProcessId, r.Process.ProcessId, "프로세스 ID 불일치"); Assert.AreEqual(e.ResponseTime, r.ResponseTime, $"{e.Process.ProcessId} 응답 시간 불일치"); Assert.AreEqual(e.WaitingTime, r.WaitingTime, $"{e.Process.ProcessId} 대기 시간 불일치"); Assert.AreEqual(e.BurstTime, r.BurstTime, $"{e.Process.ProcessId} 서비스 시간 불일치"); Assert.AreEqual(e.TurnaroundTime, r.TurnaroundTime, $"{e.Process.ProcessId} 반환 시간 불일치"); } }