本文整理汇总了C++中TaskSet::get_utilization方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskSet::get_utilization方法的具体用法?C++ TaskSet::get_utilization怎么用?C++ TaskSet::get_utilization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskSet
的用法示例。
在下文中一共展示了TaskSet::get_utilization方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is_schedulable
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;
}
示例2: is_schedulable
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;
}