diff options
author | Jeremy Erickson <jerickso@cs.unc.edu> | 2013-05-04 12:38:33 -0400 |
---|---|---|
committer | Jeremy Erickson <jerickso@cs.unc.edu> | 2013-05-04 12:38:33 -0400 |
commit | fa7932bf8c8881f2c8484d54db3ebac7b6832500 (patch) | |
tree | ded6fa80faaa72a12e92e3b1c278cd8175328479 | |
parent | f9436915a157da898b4015637b66a559dc71223b (diff) |
Properly assign cpuwip-edf-os
-rw-r--r-- | bin/rt_launch_edfos.c | 25 | ||||
-rw-r--r-- | bin/rtspin_edfos.c | 29 | ||||
-rw-r--r-- | include/litmus.h | 6 | ||||
-rw-r--r-- | src/litmus.c | 32 | ||||
-rw-r--r-- | src/task.c | 5 |
5 files changed, 62 insertions, 35 deletions
diff --git a/bin/rt_launch_edfos.c b/bin/rt_launch_edfos.c index 43ebee5..2b26fb2 100644 --- a/bin/rt_launch_edfos.c +++ b/bin/rt_launch_edfos.c | |||
@@ -50,9 +50,8 @@ int main(int argc, char** argv) | |||
50 | lt_t wcet; | 50 | lt_t wcet; |
51 | lt_t period; | 51 | lt_t period; |
52 | /* [num,den] */ | 52 | /* [num,den] */ |
53 | lt_t fracs[NR_CPUS][2]; | 53 | lt_t fracs[NR_CPUS_EDF_OS][2]; |
54 | int migrate = 0; | 54 | int cpu = -1; |
55 | int cpu = 0; | ||
56 | int opt; | 55 | int opt; |
57 | int verbose = 0; | 56 | int verbose = 0; |
58 | int wait = 0; | 57 | int wait = 0; |
@@ -60,7 +59,7 @@ int main(int argc, char** argv) | |||
60 | startup_info_t info; | 59 | startup_info_t info; |
61 | task_class_t class = RT_CLASS_HARD; | 60 | task_class_t class = RT_CLASS_HARD; |
62 | 61 | ||
63 | for (i = 0; i < NR_CPUS; i++) { | 62 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { |
64 | fracs[i][0] = 0; | 63 | fracs[i][0] = 0; |
65 | fracs[i][1] = 0; | 64 | fracs[i][1] = 0; |
66 | } | 65 | } |
@@ -77,7 +76,6 @@ int main(int argc, char** argv) | |||
77 | cpu = atoi(optarg); | 76 | cpu = atoi(optarg); |
78 | fracs[cpu][0] = 1; | 77 | fracs[cpu][0] = 1; |
79 | fracs[cpu][1] = 1; | 78 | fracs[cpu][1] = 1; |
80 | migrate = 1; | ||
81 | break; | 79 | break; |
82 | case 'c': | 80 | case 'c': |
83 | class = str2class(optarg); | 81 | class = str2class(optarg); |
@@ -106,9 +104,11 @@ int main(int argc, char** argv) | |||
106 | fracs[cpu][0] = atoi(argv[i]); | 104 | fracs[cpu][0] = atoi(argv[i]); |
107 | fracs[cpu][1] = atoi(argv[i+1]); | 105 | fracs[cpu][1] = atoi(argv[i+1]); |
108 | } | 106 | } |
107 | if (cpu == -1) | ||
108 | cpu = compute_initial_cpu_edfos(fracs); | ||
109 | if (wcet <= 0) | 109 | if (wcet <= 0) |
110 | usage("The worst-case execution time must be a " | 110 | usage("The worst-case execution time must be a " |
111 | "positive number."); | 111 | "positive number."); |
112 | if (period <= 0) | 112 | if (period <= 0) |
113 | usage("The period must be a positive number."); | 113 | usage("The period must be a positive number."); |
114 | if (wcet > period) { | 114 | if (wcet > period) { |
@@ -118,17 +118,14 @@ int main(int argc, char** argv) | |||
118 | info.exec_path = argv[optind + 8]; | 118 | info.exec_path = argv[optind + 8]; |
119 | info.argv = argv + optind + 8; | 119 | info.argv = argv + optind + 8; |
120 | info.wait = wait; | 120 | info.wait = wait; |
121 | if (migrate) { | 121 | ret = be_migrate_to(cpu); |
122 | ret = be_migrate_to(cpu); | 122 | if (ret < 0) |
123 | if (ret < 0) | 123 | bail_out("could not migrate to target partition"); |
124 | bail_out("could not migrate to target partition"); | ||
125 | } | ||
126 | /* create in src/task.c a new wrapper for the __launch_rt_task | 124 | /* create in src/task.c a new wrapper for the __launch_rt_task |
127 | * which takes the fraction and the cpus */ | 125 | * which takes the fraction and the cpus */ |
128 | ret = __create_rt_task_edfos(launch, &info, wcet, period, fracs, | 126 | ret = __create_rt_task_edfos(launch, &info, cpu, wcet, period, fracs, |
129 | class); | 127 | class); |
130 | 128 | ||
131 | |||
132 | if (ret < 0) | 129 | if (ret < 0) |
133 | bail_out("could not create rt child process"); | 130 | bail_out("could not create rt child process"); |
134 | else if (verbose) | 131 | else if (verbose) |
diff --git a/bin/rtspin_edfos.c b/bin/rtspin_edfos.c index e39a8c0..3ea41c7 100644 --- a/bin/rtspin_edfos.c +++ b/bin/rtspin_edfos.c | |||
@@ -141,10 +141,10 @@ int main(int argc, char** argv) | |||
141 | lt_t wcet; | 141 | lt_t wcet; |
142 | lt_t period; | 142 | lt_t period; |
143 | /* [num,den] */ | 143 | /* [num,den] */ |
144 | lt_t fracs[NR_CPUS][2]; | 144 | lt_t fracs[NR_CPUS_EDF_OS][2]; |
145 | double wcet_ms, period_ms; | 145 | double wcet_ms, period_ms; |
146 | int migrate = 0; | 146 | int cpu = -1; |
147 | int cpu = 0; | 147 | int ccpu; |
148 | int opt; | 148 | int opt; |
149 | int wait = 0; | 149 | int wait = 0; |
150 | int test_loop = 0; | 150 | int test_loop = 0; |
@@ -156,9 +156,9 @@ int main(int argc, char** argv) | |||
156 | 156 | ||
157 | progname = argv[0]; | 157 | progname = argv[0]; |
158 | 158 | ||
159 | for (i = 0; i < NR_CPUS; i++) { | 159 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { |
160 | fracs[i][0] = 0; | 160 | fracs[i][0] = 0; |
161 | fracs[i][1] = 1; | 161 | fracs[i][1] = 0; |
162 | } | 162 | } |
163 | 163 | ||
164 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | 164 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { |
@@ -170,7 +170,6 @@ int main(int argc, char** argv) | |||
170 | cpu = atoi(optarg); | 170 | cpu = atoi(optarg); |
171 | fracs[cpu][0] = 1; | 171 | fracs[cpu][0] = 1; |
172 | fracs[cpu][1] = 1; | 172 | fracs[cpu][1] = 1; |
173 | migrate = 1; | ||
174 | break; | 173 | break; |
175 | case 'c': | 174 | case 'c': |
176 | class = str2class(optarg); | 175 | class = str2class(optarg); |
@@ -215,10 +214,12 @@ int main(int argc, char** argv) | |||
215 | duration = atof(argv[optind + 2]); | 214 | duration = atof(argv[optind + 2]); |
216 | /* frac num, den = 0 means fixed task */ | 215 | /* frac num, den = 0 means fixed task */ |
217 | for (i = optind + 3; i < argc; i += 3) { | 216 | for (i = optind + 3; i < argc; i += 3) { |
218 | cpu = atof(argv[i]); | 217 | ccpu = atof(argv[i]); |
219 | fracs[cpu][0] = argv[i+1]; | 218 | fracs[ccpu][0] = argv[i+1]; |
220 | fracs[cpu][1] = argv[i+2]; | 219 | fracs[ccpu][1] = argv[i+2]; |
221 | } | 220 | } |
221 | if (cpu == -1) | ||
222 | cpu = compute_initial_cpu_edfos(fracs); | ||
222 | wcet = wcet_ms * __NS_PER_MS; | 223 | wcet = wcet_ms * __NS_PER_MS; |
223 | period = period_ms * __NS_PER_MS; | 224 | period = period_ms * __NS_PER_MS; |
224 | if (wcet <= 0) | 225 | if (wcet <= 0) |
@@ -231,13 +232,11 @@ int main(int argc, char** argv) | |||
231 | "exceed the period."); | 232 | "exceed the period."); |
232 | } | 233 | } |
233 | 234 | ||
234 | if (migrate) { | 235 | ret = be_migrate_to(cpu); |
235 | ret = be_migrate_to(cpu); | 236 | if (ret < 0) |
236 | if (ret < 0) | 237 | bail_out("could not migrate to target partition"); |
237 | bail_out("could not migrate to target partition"); | ||
238 | } | ||
239 | 238 | ||
240 | ret = sporadic_task_ns_edfos(wcet, period, 0, fracs, class, | 239 | ret = sporadic_task_ns_edfos(wcet, period, 0, cpu, fracs, class, |
241 | NO_ENFORCEMENT); | 240 | NO_ENFORCEMENT); |
242 | 241 | ||
243 | if (ret < 0) | 242 | if (ret < 0) |
diff --git a/include/litmus.h b/include/litmus.h index 8f997a0..0139d25 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -30,6 +30,8 @@ int get_rt_task_param(pid_t pid, struct rt_task* param); | |||
30 | 30 | ||
31 | /* setup helper */ | 31 | /* setup helper */ |
32 | 32 | ||
33 | unsigned int compute_initial_cpu_edfos(lt_t fracs[][2]); | ||
34 | |||
33 | /* times are given in ms */ | 35 | /* times are given in ms */ |
34 | int sporadic_task( | 36 | int sporadic_task( |
35 | lt_t e, lt_t p, lt_t phase, | 37 | lt_t e, lt_t p, lt_t phase, |
@@ -47,7 +49,7 @@ int sporadic_task_ns_edffm(lt_t e, lt_t p, lt_t phase, int cpu, | |||
47 | task_class_t cls, budget_policy_t budget_policy, | 49 | task_class_t cls, budget_policy_t budget_policy, |
48 | int set_cpu_set); | 50 | int set_cpu_set); |
49 | 51 | ||
50 | int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, | 52 | int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, int cpu, |
51 | lt_t fracs[][2], task_class_t cls, | 53 | lt_t fracs[][2], task_class_t cls, |
52 | budget_policy_t budget_policy); | 54 | budget_policy_t budget_policy); |
53 | 55 | ||
@@ -107,7 +109,7 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | |||
107 | int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | 109 | int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
108 | int period, lt_t *frac1, lt_t *frac2, | 110 | int period, lt_t *frac1, lt_t *frac2, |
109 | int cpu1, int cpu2, task_class_t class); | 111 | int cpu1, int cpu2, task_class_t class); |
110 | int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int wcet, | 112 | int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
111 | int period, lt_t fracs[][2], task_class_t class); | 113 | int period, lt_t fracs[][2], task_class_t class); |
112 | int __create_rt_task_npsf(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | 114 | int __create_rt_task_npsf(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
113 | int period, int npsf_id, task_class_t class); | 115 | int period, int npsf_id, task_class_t class); |
diff --git a/src/litmus.c b/src/litmus.c index b0416c4..f7c91de 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -39,6 +39,33 @@ int be_migrate_to(int target_cpu) | |||
39 | return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); | 39 | return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); |
40 | } | 40 | } |
41 | 41 | ||
42 | static unsigned int compute_pfair_deadline(lt_t wt_num, lt_t wt_den) | ||
43 | { | ||
44 | int dead; | ||
45 | dead = wt_den / wt_num; | ||
46 | if (wt_den % wt_num > 0) | ||
47 | dead++; | ||
48 | return dead; | ||
49 | } | ||
50 | |||
51 | unsigned int compute_initial_cpu_edfos(lt_t fracs[][2]) | ||
52 | { | ||
53 | int initial_cpu = -1; | ||
54 | int lowest_deadline = UINT_MAX; | ||
55 | int current_deadline, i; | ||
56 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { | ||
57 | if (fracs[i][0] > 0) { | ||
58 | current_deadline = compute_pfair_deadline(fracs[i][0], | ||
59 | fracs[i][1]); | ||
60 | if (current_deadline < lowest_deadline) { | ||
61 | lowest_deadline = current_deadline; | ||
62 | initial_cpu = i; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | return initial_cpu; | ||
67 | } | ||
68 | |||
42 | int sporadic_task(lt_t e, lt_t p, lt_t phase, | 69 | int sporadic_task(lt_t e, lt_t p, lt_t phase, |
43 | int cpu, task_class_t cls, | 70 | int cpu, task_class_t cls, |
44 | budget_policy_t budget_policy, int set_cpu_set) | 71 | budget_policy_t budget_policy, int set_cpu_set) |
@@ -107,7 +134,7 @@ int sporadic_task_ns_edffm(lt_t e, lt_t p, lt_t phase, int cpu, | |||
107 | return set_rt_task_param(gettid(), ¶m); | 134 | return set_rt_task_param(gettid(), ¶m); |
108 | } | 135 | } |
109 | 136 | ||
110 | int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, | 137 | int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, int cpu, |
111 | lt_t fracs[][2], task_class_t cls, | 138 | lt_t fracs[][2], task_class_t cls, |
112 | budget_policy_t budget_policy) | 139 | budget_policy_t budget_policy) |
113 | { | 140 | { |
@@ -118,7 +145,8 @@ int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, | |||
118 | os.first_cpu = UINT_MAX; | 145 | os.first_cpu = UINT_MAX; |
119 | param.exec_cost = e; | 146 | param.exec_cost = e; |
120 | param.period = p; | 147 | param.period = p; |
121 | for (i = 0; i < NR_CPUS; i++) { | 148 | param.cpu = cpu; |
149 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { | ||
122 | if (fracs[i][0] > 0) { | 150 | if (fracs[i][0] > 0) { |
123 | os.migrat++; | 151 | os.migrat++; |
124 | if (os.first_cpu == UINT_MAX) | 152 | if (os.first_cpu == UINT_MAX) |
@@ -71,12 +71,13 @@ int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | |||
71 | (rt_setup_fn_t) set_rt_task_param, ¶ms); | 71 | (rt_setup_fn_t) set_rt_task_param, ¶ms); |
72 | } | 72 | } |
73 | 73 | ||
74 | int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int wcet, | 74 | int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
75 | int period, lt_t fracs[][2], task_class_t class) | 75 | int period, lt_t fracs[][2], task_class_t class) |
76 | { | 76 | { |
77 | struct rt_task params; | 77 | struct rt_task params; |
78 | struct edfos_params os; | 78 | struct edfos_params os; |
79 | int i; | 79 | int i; |
80 | params.cpu = cpu; | ||
80 | params.period = period; | 81 | params.period = period; |
81 | params.exec_cost = wcet; | 82 | params.exec_cost = wcet; |
82 | params.cls = class; | 83 | params.cls = class; |
@@ -86,7 +87,7 @@ int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int wcet, | |||
86 | 87 | ||
87 | os.migrat = 0; | 88 | os.migrat = 0; |
88 | os.first_cpu = UINT_MAX; | 89 | os.first_cpu = UINT_MAX; |
89 | for (i = 0; i < NR_CPUS; i++) { | 90 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { |
90 | if (fracs[i][0] > 0) { | 91 | if (fracs[i][0] > 0) { |
91 | os.migrat++; | 92 | os.migrat++; |
92 | if (os.first_cpu == UINT_MAX) | 93 | if (os.first_cpu == UINT_MAX) |