From 6fc64ec121241607139ecef9ec2bd9be16603dde Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 22 Sep 2010 14:36:02 -0400 Subject: avoid inconsistencies in the task parameters Floating point conversions introduce rounding errors. Fix-up the total execution cost as the sum of individual budgets. --- bin/common.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/common.c b/bin/common.c index 9cb577b..b43ebf3 100644 --- a/bin/common.c +++ b/bin/common.c @@ -37,12 +37,16 @@ void bail_out(const char* msg) * . */ int parse_edfwm_slice(FILE *ts, int slices_no, int task_id, - struct edf_wm_params *wm) + struct rt_task *rt) { int i, tid; unsigned int cpu; double deadline, budget, offset; + lt_t total_budget = 0; + + struct edf_wm_params* wm = (struct edf_wm_params*) &rt->semi_part; + for (i = 0; i < slices_no; i++) { if (fscanf(ts, "%d %u %lf %lf %lf\n", &tid, &cpu, @@ -62,6 +66,8 @@ int parse_edfwm_slice(FILE *ts, int slices_no, int task_id, printf("slice(tid, cpu, d, e, ph) = (%d, %u, %llu, %llu, %llu)\n", tid, cpu, wm->slices[i].deadline, wm->slices[i].budget, wm->slices[i].offset); + + total_budget += wm->slices[i].budget; } if (ferror(ts)) { @@ -70,6 +76,7 @@ int parse_edfwm_slice(FILE *ts, int slices_no, int task_id, } } wm->count = slices_no; + rt->exec_cost = total_budget; printf("--- total %u slices ---\n", wm->count); return 0; } @@ -101,8 +108,7 @@ int parse_edfwm_ts_file(FILE *ts, struct rt_task *rt) task_id, rt->exec_cost, rt->period, rt->phase, cpu, sliceno); if (sliceno > 0) { memset(&rt->semi_part, 0, sizeof(struct edf_wm_params)); - ret = parse_edfwm_slice(ts, sliceno, task_id, - (struct edf_wm_params*) &rt->semi_part); + ret = parse_edfwm_slice(ts, sliceno, task_id, rt); if (ret < 0) goto err; } -- cgit v1.2.2