bool BaruahGedf::is_task_schedulable(unsigned int k, const TaskSet &ts, const integral_t &ilen, integral_t &i1, integral_t &sum, integral_t *idiff, integral_t **ptr) { integral_t bound; sum = 0; for (unsigned int i = 0; i < ts.get_task_count(); i++) { interval1(i, k, ts, ilen, i1); interval2(i, k, ts, ilen, idiff[i]); sum += i1; idiff[i] -= i1; } /* sort pointers to idiff to find largest idiff values */ sort(ptr, ptr + ts.get_task_count(), MPZComparator()); for (unsigned int i = 0; i < m - 1 && i < ts.get_task_count(); i++) sum += *ptr[i]; bound = ilen + ts[k].get_deadline() - ts[k].get_wcet(); bound *= m; return sum <= bound; }
void init(const TaskSet &ts, int k, integral_t* bound) { last = -1; dbf = new DBFPointsOfChange[ts.get_task_count()]; for (unsigned int i = 0; i < ts.get_task_count(); i++) { dbf[i].init(ts[i], ts[k]); queue.push(dbf + i); } upper_bound = bound; }
bool RTAGedf::is_schedulable(const TaskSet &ts, bool check_preconditions) { if (check_preconditions) { if (!(ts.has_only_feasible_tasks() && ts.is_not_overutilized(m) && ts.has_only_constrained_deadlines() && ts.has_only_feasible_tasks())) return false; if (ts.get_task_count() == 0) return true; } unsigned long* slack = new unsigned long[ts.get_task_count()]; for (unsigned int i = 0; i < ts.get_task_count(); i++) slack[i] = 0; unsigned long round = 0; bool schedulable = false; bool updated = true; while (updated && !schedulable && (max_rounds == 0 || round < max_rounds)) { round++; schedulable = true; updated = false; for (unsigned int k = 0; k < ts.get_task_count(); k++) { unsigned long response, new_slack; if (rta_fixpoint(k, ts, slack, response)) { new_slack = ts[k].get_deadline() - response; if (new_slack != slack[k]) { slack[k] = new_slack; updated = true; } } else { schedulable = false; } } } return schedulable; }
bool BCLGedf::is_task_schedulable(unsigned int k, const TaskSet &ts) { fractional_t beta_i, beta_sum = 0; fractional_t lambda_term; bool small_beta_exists = false; ts[k].get_density(lambda_term); lambda_term *= -1; lambda_term += 1; for (unsigned int i = 0; i < ts.get_task_count(); i++) { if (i != k) { beta(ts[i], ts[k], beta_i); beta_sum += min(beta_i, lambda_term); small_beta_exists = small_beta_exists || (0 < beta_i && beta_i <= lambda_term); } } lambda_term *= m; return beta_sum < lambda_term || (small_beta_exists && beta_sum == lambda_term); }
bool RTAGedf::response_estimate(unsigned int k, const TaskSet &ts, unsigned long const *slack, unsigned long response, unsigned long &new_response) { integral_t other_work = 0; integral_t inf_edf; integral_t inf_rta; integral_t inf_bound = response - ts[k].get_wcet() + 1; integral_t tmp; for (unsigned int i = 0; i < ts.get_task_count(); i++) if (k != i) { edf_interfering_workload(ts[i], ts[k], slack[i], inf_edf); rta_interfering_workload(ts[i], response, slack[i], inf_rta, tmp); other_work += min(min(inf_edf, inf_rta), inf_bound); } /* implicit floor */ other_work /= m; other_work += ts[k].get_wcet(); if (other_work.fits_ulong_p()) { new_response = other_work.get_ui(); return true; } else { /* overflowed => reponse time > deadline */ return false; } }
static void ffdbf_ts(const TaskSet &ts, const integral_t q[], const fractional_t r[], const fractional_t &time, const fractional_t &speed, fractional_t &demand, fractional_t &tmp) { demand = 0; for (unsigned int i = 0; i < ts.get_task_count(); i++) ffdbf(ts[i], time, speed, q[i], r[i], demand, tmp); }
int xxxxmain(int argc, char** argv) { GlobalScheduler<EarliestDeadlineFirst> theSim(24); TaskSet* ts = init_baruah(); PeriodicJobSequence** gen; gen = new PeriodicJobSequence*[ts->get_task_count()]; for (unsigned int i = 0; i < ts->get_task_count(); i++) { gen[i] = new PeriodicJobSequence((*ts)[i]); gen[i]->set_simulation(&theSim); theSim.add_release(gen[i]); } theSim.simulate_until(1000 * 1000 * 1000); // 1000 seconds return 0; }
bool BCLIterativeGedf::is_schedulable(const TaskSet &ts, bool check_preconditions) { if (check_preconditions) { if (!(ts.has_only_feasible_tasks() && ts.is_not_overutilized(m) && ts.has_only_constrained_deadlines())) return false; if (ts.get_task_count() == 0) return true; } unsigned long* slack = new unsigned long[ts.get_task_count()]; for (unsigned int i = 0; i < ts.get_task_count(); i++) slack[i] = 0; unsigned long round = 0; bool schedulable = false; bool updated = true; while (updated && !schedulable && (max_rounds == 0 || round < max_rounds)) { round++; schedulable = true; updated = false; for (unsigned int k = 0; k < ts.get_task_count(); k++) { bool ok; if (slack_update(k, ts, slack, ok)) updated = true; schedulable = schedulable && ok; } } return schedulable; }
bool BCLGedf::is_schedulable(const TaskSet &ts, bool check_preconditions) { if (check_preconditions) { if (!(ts.has_only_feasible_tasks() && ts.is_not_overutilized(m) && ts.has_only_constrained_deadlines())) return false; } for (unsigned int k = 0; k < ts.get_task_count(); k++) if (!is_task_schedulable(k, ts)) return false; return true; }
bool BCLIterativeGedf::slack_update(unsigned int k, const TaskSet &ts, unsigned long *slack, bool &has_slack) { integral_t other_work = 0; integral_t inf; integral_t inf_bound = ts[k].get_deadline() - ts[k].get_wcet() + 1; for (unsigned int i = 0; i < ts.get_task_count(); i++) if (k != i) { interfering_workload(ts[i], ts[k], slack[i], inf); other_work += min(inf, inf_bound); } other_work /= m; unsigned long tmp = ts[k].get_wcet() + other_work.get_ui(); assert( other_work.fits_ulong_p() ); assert (tmp > other_work.get_ui() ); has_slack = tmp <= ts[k].get_deadline(); if (!has_slack) // negative slack => no update, always assume zero return false; else { tmp = ts[k].get_deadline() - tmp; if (tmp > slack[k]) { // better slack => update slack[k] = tmp; return true; } else // no improvement return false; } }
void BaruahGedf::get_max_test_points(const TaskSet &ts, fractional_t &m_minus_u, integral_t* maxp) { unsigned long* wcet = new unsigned long[ts.get_task_count()]; for (unsigned int i = 0; i < ts.get_task_count(); i++) wcet[i] = ts[i].get_wcet(); sort(wcet, wcet + ts.get_task_count(), greater<unsigned long>()); fractional_t u, tdu_sum; integral_t csigma, mc; csigma = 0; for (unsigned int i = 0; i < m - 1 && i < ts.get_task_count(); i++) csigma += wcet[i]; tdu_sum = 0; for (unsigned int i = 0; i < ts.get_task_count(); i++) { ts[i].get_utilization(u); tdu_sum += (ts[i].get_period() - ts[i].get_deadline()) * u; } for (unsigned int i = 0; i < ts.get_task_count(); i++) { mc = ts[i].get_wcet(); mc *= m; mc += 0.124; maxp[i] = (csigma - (ts[i].get_deadline() * m_minus_u) + tdu_sum + mc) / m_minus_u; } delete wcet; }
static void compute_q_r(const TaskSet &ts, const fractional_t &time, integral_t q[], fractional_t r[]) { for (unsigned int i = 0; i < ts.get_task_count(); i++) get_q_r(ts[i], time, q[i], r[i]); }
bool FFDBFGedf::is_schedulable(const TaskSet &ts, bool check_preconditions) { if (m < 2) return false; if (check_preconditions) { if (!(ts.has_only_feasible_tasks() && ts.is_not_overutilized(m) && ts.has_only_constrained_deadlines() && ts.has_no_self_suspending_tasks())) return false; } // allocate helpers AllTestPoints testing_set(ts); integral_t *q = new integral_t[ts.get_task_count()]; fractional_t *r = new fractional_t[ts.get_task_count()]; fractional_t sigma_bound; fractional_t time_bound; fractional_t tmp(1, epsilon_denom); // compute sigma bound tmp = 1; tmp /= epsilon_denom; ts.get_utilization(sigma_bound); sigma_bound -= m; sigma_bound /= - ((int) (m - 1)); // neg. to flip sign sigma_bound -= tmp; // epsilon sigma_bound = min(sigma_bound, fractional_t(1)); // compute time bound time_bound = 0; for (unsigned int i = 0; i < ts.get_task_count(); i++) time_bound += ts[i].get_wcet(); time_bound /= tmp; // epsilon fractional_t t_cur; fractional_t sigma_cur, sigma_nxt; bool schedulable; t_cur = 0; schedulable = false; // Start with minimum possible sigma value, then try // multiples of sigma_step. ts.get_max_density(sigma_cur); // setup brute force sigma value range sigma_nxt = sigma_cur / sigma_step; truncate_fraction(sigma_nxt); sigma_nxt += 1; sigma_nxt *= sigma_step; while (!schedulable && sigma_cur <= sigma_bound && t_cur <= time_bound) { testing_set.init(sigma_cur, t_cur); do { testing_set.get_next(t_cur); if (t_cur <= time_bound) { compute_q_r(ts, t_cur, q, r); schedulable = witness_condition(ts, q, r, t_cur, sigma_cur); } else // exceeded testing interval schedulable = true; } while (t_cur <= time_bound && schedulable); if (!schedulable && t_cur <= time_bound) { // find next sigma variable do { sigma_cur = sigma_nxt; sigma_nxt += sigma_step; } while (sigma_cur <= sigma_bound && !witness_condition(ts, q, r, t_cur, sigma_cur)); } } delete [] q; delete [] r; return schedulable; }
AllTestPoints(const TaskSet &ts) : ts(ts) { pts = new TestPoints[ts.get_task_count()]; }
bool BaruahGedf::is_schedulable(const TaskSet &ts, bool check_preconditions) { if (check_preconditions) { if (!(ts.has_only_feasible_tasks() && ts.is_not_overutilized(m) && ts.has_only_constrained_deadlines())) return false; if (ts.get_task_count() == 0) return true; } fractional_t m_minus_u; ts.get_utilization(m_minus_u); m_minus_u *= -1; m_minus_u += m; if (m_minus_u <= 0) { // Baruah's G-EDF test requires strictly positive slack. // In the case of zero slack the testing interval becomes // infinite. Therefore, we can't do anything but bail out. return false; } double start_time = get_cpu_usage(); integral_t i1, sum; integral_t *max_test_point, *idiff; integral_t** ptr; // indirect access to idiff idiff = new integral_t[ts.get_task_count()]; max_test_point = new integral_t[ts.get_task_count()]; ptr = new integral_t*[ts.get_task_count()]; for (unsigned int i = 0; i < ts.get_task_count(); i++) ptr[i] = idiff + i; get_max_test_points(ts, m_minus_u, max_test_point); integral_t ilen; bool point_in_range = true; bool schedulable = true; AllDBFPointsOfChange *all_pts; all_pts = new AllDBFPointsOfChange[ts.get_task_count()]; for (unsigned int k = 0; k < ts.get_task_count() && schedulable; k++) all_pts[k].init(ts, k, max_test_point + k); // for every task for which point <= max_ak unsigned long iter_count = 0; while (point_in_range && schedulable) { point_in_range = false; // check for excessive run time every 10 iterations if (++iter_count % 10 == 0 && get_cpu_usage() > start_time + MAX_RUNTIME) { // This is taking too long. Give up. schedulable = false; break; } for (unsigned int k = 0; k < ts.get_task_count() && schedulable; k++) if (all_pts[k].get_next(ilen)) { schedulable = is_task_schedulable(k, ts, ilen, i1, sum, idiff, ptr); point_in_range = true; } } delete[] all_pts; delete[] max_test_point; delete[] idiff; delete[] ptr; return schedulable; }