public static Image CalcFCFS(TextBox turnaroundtime, TextBox waittime) { var SchedulingNameList = new List <string>(); var CPUList = new List <double> { 0.0 }; var arrivalList = ArrivalTime.Select(s => double.Parse(s.Text)).ToList(); var at = arrivalList.OrderBy(sort => sort).ToList(); var CPUBurstTimeList = CPUBurstTime.Select(textbox => double.Parse(textbox.Text)).ToList(); var TurnaroundTime = 0.0; var WaitTime = 0.0; var TotalTime = 0.0; turnaroundtime.Text = "( "; waittime.Text = "( "; var index = 0; for (int i = 0; i < arrivalList.Count; i++) { index = arrivalList.FindIndex(value => value == at[i]); if (index == -1) { continue; } while (CPUBurstTimeList[index] == 0) { index = arrivalList.FindIndex(index + 1, value => value == at[i]); } if (TotalTime < arrivalList[index]) { SchedulingNameList.Add("空"); TotalTime = arrivalList[index]; CPUList.Add(TotalTime); } SchedulingNameList.Add(SchedulingName[index].Text); TotalTime += CPUBurstTimeList[index]; var tt = TotalTime - arrivalList[index]; TurnaroundTime += tt; turnaroundtime.AppendText($"{tt} + "); var wt = TotalTime - arrivalList[index] - CPUBurstTimeList[index]; WaitTime += wt; waittime.AppendText($"{wt} + "); CPUList.Add(TotalTime); CPUBurstTimeList[index] = 0; } turnaroundtime.Text = turnaroundtime.Text.TrimEnd(new char[] { ' ', '+' }); waittime.Text = waittime.Text.TrimEnd(new char[] { ' ', '+' }); turnaroundtime.AppendText($" ) / {SchedulingName.Length} = {TurnaroundTime / SchedulingName.Length}"); waittime.AppendText($" ) / {SchedulingName.Length} = {WaitTime / SchedulingName.Length}"); return(DrawingSort.DrawStart(CPUList, SchedulingNameList)); }
public static Image CalcSRT(TextBox turnaroundtime, TextBox waittime) { var SchedulingNameList = new List <string>(); var CPUList = new List <double> { 0.0 }; var arrivalList = ArrivalTime.Select(s => double.Parse(s.Text)).ToList(); var at = arrivalList.OrderBy(sort => sort).ToList(); var CPUBurstTimeList = CPUBurstTime.Select(textbox => double.Parse(textbox.Text)).ToList(); var TurnaroundTime = 0.0; var WaitTime = 0.0; var TotalTime = 0.0; turnaroundtime.Text = "( "; waittime.Text = "( "; return(DrawingSort.DrawStart(CPUList, SchedulingNameList)); }