private double GetUtilizationOfWorkload(DataTable dt) { double SumUtilization = 0; foreach (DataRow dr in dt.Rows) { Task t = new Task(dr); SumUtilization += t.Utilization; } return SumUtilization; }
private long GetLCM_forWorkload(DataTable dt) { Task firstTask = new Task(dt.Rows[0]); long LCM = (long)firstTask.Period; foreach (DataRow dr in dt.Rows) { Task t = new Task(dr); LCM = GetLCM(LCM, (long)t.Period); } return LCM; }
private void buttonCheck_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; List<Task> listTask = new List<Task>(); Task taskEms = new Task( double.Parse(textBoxEmsPi.Text), double.Parse(textBoxEmsTheta.Text), double.Parse(textBoxEmsPi.Text), // deadline = period 0); Task taskTms = new Task( double.Parse(textBoxTmsPi.Text), double.Parse(textBoxTmsTheta.Text), double.Parse(textBoxTmsPi.Text), // deadline = period 0); listTask.Add(taskEms); listTask.Add(taskTms); DataTable dtSync = dataGridViewSync.DataSource as DataTable; foreach (DataRow dr in dtSync.Rows) { Task t = new Task( double.Parse(dr["Period"].ToString()), double.Parse(dr["ExecutionTime"].ToString()) + 2 * _overhead, double.Parse(dr["ExecutionTime"].ToString()) + 2 * _overhead, // deadline = execution double.Parse(dr["Phase"].ToString()), 0); listTask.Add(t); } double interval = listTask[0].Period; foreach (Task t in listTask) { interval = (double)GetLCM((long)interval, (long)t.Period); } FormChart chart = new FormChart("Resource demand / supply"); chart.GetLable.Text = "Schedulable"; try { Series seriesDBF = new Series("Resource Demand"); seriesDBF.ChartArea = "ChartArea1"; seriesDBF.ChartType = SeriesChartType.StepLine; seriesDBF.Legend = "Legend1"; seriesDBF.Color = Color.Blue; Series seriesSBF = new Series("Resurce Supply"); seriesSBF.ChartArea = "ChartArea1"; seriesSBF.ChartType = SeriesChartType.Line; seriesSBF.Legend = "Legend1"; seriesSBF.Color = Color.Red; DataTable dt = GetSelectedTaskSet(); for (double t = 0; t <= interval; t += 1) { double dbf = GetDBF_Sporadic_EDF(listTask, t); if (dbf > t) chart.GetLable.Text = "Not Schedulable"; seriesDBF.Points.Add(new DataPoint(t, dbf)); seriesSBF.Points.Add(new DataPoint(t, t)); } chart.AxisX.Title = "Interval Length"; chart.AxisY.Title = "Resource demand / supply"; chart.AxisX.Minimum = 0; chart.AddSeries(seriesDBF); chart.AddSeries(seriesSBF); } finally { this.Cursor = Cursors.Default; } chart.Show(); }
private List<long> GetList(DataTable dt) { List<long> list = new List<long>(); long lcm = GetLCM_forWorkload(dt); foreach (DataRow dr in dt.Rows) { Task t = new Task(dr); for (long i = 0; i <= lcm / t.Period; i++) { long current = i * (long)t.Period; if (false == list.Contains(current)) list.Add(current); } } list.Sort(); return list; }
private bool CheckSchedulabilityRM(DataTable dt, double pi, double theta) { bool TrueForAllTasks = true; foreach (DataRow dr in dt.Rows) { Task t = new Task(dr); double dbf = GetDBF_RM(dt, t.Period, t.Priority, _overhead); double sbf = GetSBF_RM(t.Period, pi, theta); if (dbf > sbf) TrueForAllTasks = false; } return TrueForAllTasks; }