diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-09-22 14:36:02 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-01-26 18:20:24 -0500 |
commit | 8d44dbc64140ccf56471bbec26bc70aa756a3d0d (patch) | |
tree | 6659001e9bbc9f8beb9697a6225b165efc0783c6 | |
parent | bdfa2690041f828c64e7151bad29f858c4d3c2a6 (diff) |
avoid inconsistencies in the task parameters
Floating point conversions introduce rounding errors.
Fix-up the total execution cost as the sum of individual budgets.
-rw-r--r-- | bin/common.c | 12 |
1 files 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) | |||
37 | * <task_id, cpu, deadline (from job release), budget, offset> . | 37 | * <task_id, cpu, deadline (from job release), budget, offset> . |
38 | */ | 38 | */ |
39 | int parse_edfwm_slice(FILE *ts, int slices_no, int task_id, | 39 | int parse_edfwm_slice(FILE *ts, int slices_no, int task_id, |
40 | struct edf_wm_params *wm) | 40 | struct rt_task *rt) |
41 | { | 41 | { |
42 | int i, tid; | 42 | int i, tid; |
43 | unsigned int cpu; | 43 | unsigned int cpu; |
44 | double deadline, budget, offset; | 44 | double deadline, budget, offset; |
45 | 45 | ||
46 | lt_t total_budget = 0; | ||
47 | |||
48 | struct edf_wm_params* wm = (struct edf_wm_params*) &rt->semi_part; | ||
49 | |||
46 | for (i = 0; i < slices_no; i++) { | 50 | for (i = 0; i < slices_no; i++) { |
47 | 51 | ||
48 | if (fscanf(ts, "%d %u %lf %lf %lf\n", &tid, &cpu, | 52 | 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, | |||
62 | printf("slice(tid, cpu, d, e, ph) = (%d, %u, %llu, %llu, %llu)\n", | 66 | printf("slice(tid, cpu, d, e, ph) = (%d, %u, %llu, %llu, %llu)\n", |
63 | tid, cpu, wm->slices[i].deadline, | 67 | tid, cpu, wm->slices[i].deadline, |
64 | wm->slices[i].budget, wm->slices[i].offset); | 68 | wm->slices[i].budget, wm->slices[i].offset); |
69 | |||
70 | total_budget += wm->slices[i].budget; | ||
65 | } | 71 | } |
66 | 72 | ||
67 | if (ferror(ts)) { | 73 | if (ferror(ts)) { |
@@ -70,6 +76,7 @@ int parse_edfwm_slice(FILE *ts, int slices_no, int task_id, | |||
70 | } | 76 | } |
71 | } | 77 | } |
72 | wm->count = slices_no; | 78 | wm->count = slices_no; |
79 | rt->exec_cost = total_budget; | ||
73 | printf("--- total %u slices ---\n", wm->count); | 80 | printf("--- total %u slices ---\n", wm->count); |
74 | return 0; | 81 | return 0; |
75 | } | 82 | } |
@@ -101,8 +108,7 @@ int parse_edfwm_ts_file(FILE *ts, struct rt_task *rt) | |||
101 | task_id, rt->exec_cost, rt->period, rt->phase, cpu, sliceno); | 108 | task_id, rt->exec_cost, rt->period, rt->phase, cpu, sliceno); |
102 | if (sliceno > 0) { | 109 | if (sliceno > 0) { |
103 | memset(&rt->semi_part, 0, sizeof(struct edf_wm_params)); | 110 | memset(&rt->semi_part, 0, sizeof(struct edf_wm_params)); |
104 | ret = parse_edfwm_slice(ts, sliceno, task_id, | 111 | ret = parse_edfwm_slice(ts, sliceno, task_id, rt); |
105 | (struct edf_wm_params*) &rt->semi_part); | ||
106 | if (ret < 0) | 112 | if (ret < 0) |
107 | goto err; | 113 | goto err; |
108 | } | 114 | } |