diff options
| author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-09-18 07:51:05 -0400 |
|---|---|---|
| committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-03-16 10:33:22 -0400 |
| commit | 0d3feb83a642dc05a7d4e06876ce494832ff5db7 (patch) | |
| tree | a12731eb46c652a8398a28ba1a5aac2255ba84a5 /bin | |
| parent | 13559d16bcd773dcea0fdcb69a60a2fe15ad9fd8 (diff) | |
Add -R (create sporadic reservation) flag to rtspin
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/rtspin.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c index d36c424..44073cc 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <stdio.h> | 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
| 5 | #include <unistd.h> | 5 | #include <unistd.h> |
| 6 | #include <limits.h> | ||
| 6 | #include <time.h> | 7 | #include <time.h> |
| 7 | #include <string.h> | 8 | #include <string.h> |
| 8 | #include <assert.h> | 9 | #include <assert.h> |
| @@ -184,17 +185,18 @@ static int job(double exec_time, double program_end, int lock_od, double cs_leng | |||
| 184 | } | 185 | } |
| 185 | } | 186 | } |
| 186 | 187 | ||
| 187 | #define OPTSTR "p:c:wlveo:f:s:q:r:X:L:Q:vi" | 188 | #define OPTSTR "p:c:wlveo:f:s:q:r:X:L:Q:viR" |
| 188 | int main(int argc, char** argv) | 189 | int main(int argc, char** argv) |
| 189 | { | 190 | { |
| 190 | int ret; | 191 | int ret; |
| 191 | lt_t wcet; | 192 | lt_t wcet; |
| 192 | lt_t period; | 193 | lt_t period; |
| 193 | double wcet_ms, period_ms; | 194 | double wcet_ms, period_ms; |
| 194 | unsigned int priority = LITMUS_LOWEST_PRIORITY; | 195 | unsigned int priority = LITMUS_NO_PRIORITY; |
| 195 | int migrate = 0; | 196 | int migrate = 0; |
| 196 | int cluster = 0; | 197 | int cluster = 0; |
| 197 | int reservation = -1; | 198 | int reservation = -1; |
| 199 | int create_reservation = -1; | ||
| 198 | int opt; | 200 | int opt; |
| 199 | int wait = 0; | 201 | int wait = 0; |
| 200 | int test_loop = 0; | 202 | int test_loop = 0; |
| @@ -235,6 +237,10 @@ int main(int argc, char** argv) | |||
| 235 | case 'r': | 237 | case 'r': |
| 236 | reservation = atoi(optarg); | 238 | reservation = atoi(optarg); |
| 237 | break; | 239 | break; |
| 240 | case 'R': | ||
| 241 | create_reservation = 1; | ||
| 242 | reservation = getpid(); | ||
| 243 | break; | ||
| 238 | case 'q': | 244 | case 'q': |
| 239 | priority = atoi(optarg); | 245 | priority = atoi(optarg); |
| 240 | if (!litmus_is_valid_fixed_prio(priority)) | 246 | if (!litmus_is_valid_fixed_prio(priority)) |
| @@ -346,7 +352,7 @@ int main(int argc, char** argv) | |||
| 346 | init_rt_task_param(¶m); | 352 | init_rt_task_param(¶m); |
| 347 | param.exec_cost = wcet; | 353 | param.exec_cost = wcet; |
| 348 | param.period = period; | 354 | param.period = period; |
| 349 | param.priority = priority; | 355 | param.priority = priority == LITMUS_NO_PRIORITY ? LITMUS_LOWEST_PRIORITY : priority; |
| 350 | param.cls = class; | 356 | param.cls = class; |
| 351 | param.budget_policy = (want_enforcement) ? | 357 | param.budget_policy = (want_enforcement) ? |
| 352 | PRECISE_ENFORCEMENT : NO_ENFORCEMENT; | 358 | PRECISE_ENFORCEMENT : NO_ENFORCEMENT; |
| @@ -360,6 +366,20 @@ int main(int argc, char** argv) | |||
| 360 | if (ret < 0) | 366 | if (ret < 0) |
| 361 | bail_out("could not setup rt task params"); | 367 | bail_out("could not setup rt task params"); |
| 362 | 368 | ||
| 369 | if (create_reservation) { | ||
| 370 | struct reservation_config config; | ||
| 371 | memset(&config, 0, sizeof(config)); | ||
| 372 | config.id = gettid(); | ||
| 373 | config.cpu = domain_to_first_cpu(cluster); | ||
| 374 | config.priority = priority; | ||
| 375 | config.polling_params.budget = wcet; | ||
| 376 | config.polling_params.period = period; | ||
| 377 | config.polling_params.relative_deadline = period; | ||
| 378 | ret = reservation_create(SPORADIC_POLLING, &config); | ||
| 379 | if (ret < 0) | ||
| 380 | bail_out("failed to create reservation"); | ||
| 381 | } | ||
| 382 | |||
| 363 | init_litmus(); | 383 | init_litmus(); |
| 364 | 384 | ||
| 365 | start = wctime(); | 385 | start = wctime(); |
