public bool RMS(Task[] tasks, TaskSetInfo tasksetinfo) { bool feasible = false; //Uses RMS to return true if feasible, false if not for (int i = 0; i <= tasksetinfo.PeriodLCM; i++) { } if (feasible == true) { return(true); } else { return(false); } }
private void cmdGo_Click(object sender, EventArgs e) { int i, n = 0; double period, execution, total_utilization = 0; if (!String.IsNullOrWhiteSpace(txtTask1Period.Text)) { n++; } if (!String.IsNullOrWhiteSpace(txtTask2Period.Text)) { n++; } if (!String.IsNullOrWhiteSpace(txtTask3Period.Text)) { n++; } if (!String.IsNullOrWhiteSpace(txtTask4Period.Text)) { n++; } if (!String.IsNullOrWhiteSpace(txtTask5Period.Text)) { n++; } double[] numbers = new double[n]; Task[] tasks = new Task[n]; for (i = 0; i < n; i++) { switch (i) { case 0: double.TryParse(txtTask1Period.Text, out period); double.TryParse(txtTask1Execution.Text, out execution); numbers[i] = period; tasks[i] = new Task(i, period, execution); txtTask1Utilization.Text = tasks[i].Utilization.ToString(); break; case 1: double.TryParse(txtTask2Period.Text, out period); double.TryParse(txtTask2Execution.Text, out execution); numbers[i] = period; tasks[i] = new Task(i, period, execution); txtTask2Utilization.Text = tasks[i].Utilization.ToString(); break; case 2: double.TryParse(txtTask3Period.Text, out period); double.TryParse(txtTask3Execution.Text, out execution); numbers[i] = period; tasks[i] = new Task(i, period, execution); txtTask3Utilization.Text = tasks[i].Utilization.ToString(); break; case 3: double.TryParse(txtTask4Period.Text, out period); double.TryParse(txtTask4Execution.Text, out execution); numbers[i] = period; tasks[i] = new Task(i, period, execution); txtTask4Utilization.Text = tasks[i].Utilization.ToString(); break; case 4: double.TryParse(txtTask5Period.Text, out period); double.TryParse(txtTask5Execution.Text, out execution); numbers[i] = period; tasks[i] = new Task(i, period, execution); txtTask5Utilization.Text = tasks[i].Utilization.ToString(); break; default: break; } total_utilization += tasks[i].Utilization; } TaskSetInfo tasksetinfo = new TaskSetInfo(n, total_utilization); tasksetinfo.FindLCM(numbers); for (i = 0; i < n; i++) { tasks[i].FindDeadlines(tasksetinfo.PeriodLCM); } txtTotalUtilization.Text = tasksetinfo.TotalUtilization.ToString(); txtOverloaded.Text = tasksetinfo.Overload.ToString(); txtGuaranteedLevel.Text = tasksetinfo.GuaranteedLevel.ToString(); txtGuaranteed.Text = tasksetinfo.Guaranteed.ToString(); txtLCM.Text = tasksetinfo.PeriodLCM.ToString(); if (tasksetinfo.Overload == true && tasksetinfo.Feasible == false) { txtFeasible.Text = "No, overloaded"; } else if (tasksetinfo.Guaranteed == true && tasksetinfo.Feasible == true) { txtFeasible.Text = "Yes, guaranteed by RMS"; } else if (tasksetinfo.Guaranteed == false) { txtFeasible.Text = "Unclear, test up to LCM of periods"; } cmdRandom.Enabled = false; cmdGo.Enabled = false; }