aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2016-02-12 05:11:59 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-03-20 14:07:43 -0400
commite742799900ccb9451ee501ffa614c3f4c8c48b32 (patch)
treeab7ca0331593f8a8083d8104a82cf01c968eedba
parenta409d6c24a9d1035f6c5f26248651aa83ea8d727 (diff)
Add -b (background cache-thrashing loop) option to rtspin
-rw-r--r--bin/rtspin.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c
index e45f376..151b545 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -17,22 +17,29 @@
17 17
18 18
19static void usage(char *error) { 19static void usage(char *error) {
20 fprintf(stderr, "Error: %s\n", error); 20 if (error)
21 fprintf(stderr, "Error: %s\n", error);
21 fprintf(stderr, 22 fprintf(stderr,
22 "Usage:\n" 23 "Usage:\n"
23 " rt_spin [COMMON-OPTS] WCET PERIOD DURATION\n" 24 " (1) rtspin [COMMON-OPTS] WCET PERIOD DURATION\n"
24 " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n" 25 " (2) rtspin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n"
25 " rt_spin -l\n" 26 " (3) rtspin -l\n"
27 " (4) rtspin -B\n"
28 "\n"
29 "Modes: (1) run as periodic task with given WCET and PERIOD\n"
30 " (2) as (1), but load per-job execution times from CSV file\n"
31 " (3) Run calibration loop (how accurately are target runtimes met?)\n"
32 " (4) Run background, non-real-time cache-thrashing loop (w/ -m).\n"
26 "\n" 33 "\n"
27 "COMMON-OPTS = [-w] [-s SCALE]\n" 34 "COMMON-OPTS = [-w] [-s SCALE]\n"
28 " [-p PARTITION/CLUSTER [-z CLUSTER SIZE]] [-c CLASS]\n" 35 " [-p PARTITION/CLUSTER [-z CLUSTER SIZE]] [-c CLASS]\n"
29 " [-X LOCKING-PROTOCOL] [-L CRITICAL SECTION LENGTH] [-Q RESOURCE-ID]\n" 36 " [-X LOCKING-PROTOCOL] [-L CRITICAL SECTION LENGTH] [-Q RESOURCE-ID]\n"
30 " [-m RESIDENT SET SIZE]" 37 " [-m RESIDENT SET SIZE]\n"
31 "\n" 38 "\n"
32 "WCET and PERIOD are milliseconds, DURATION is seconds.\n" 39 "WCET and PERIOD are milliseconds, DURATION is seconds.\n"
33 "CRITICAL SECTION LENGTH is in milliseconds.\n" 40 "CRITICAL SECTION LENGTH is in milliseconds.\n"
34 "RESIDENT SET SIZE is in number of pages\n"); 41 "RESIDENT SET SIZE is in number of pages\n");
35 exit(EXIT_FAILURE); 42 exit(error ? EXIT_FAILURE : EXIT_SUCCESS);
36} 43}
37 44
38/* 45/*
@@ -207,7 +214,7 @@ static int job(double exec_time, double program_end, int lock_od, double cs_leng
207 } 214 }
208} 215}
209 216
210#define OPTSTR "p:c:wlveo:f:s:m:q:r:X:L:Q:viRu:B:" 217#define OPTSTR "p:c:wlveo:f:s:m:q:r:X:L:Q:viRu:Bh"
211int main(int argc, char** argv) 218int main(int argc, char** argv)
212{ 219{
213 int ret; 220 int ret;
@@ -222,6 +229,7 @@ int main(int argc, char** argv)
222 int opt; 229 int opt;
223 int wait = 0; 230 int wait = 0;
224 int test_loop = 0; 231 int test_loop = 0;
232 int background_loop = 0;
225 int column = 1; 233 int column = 1;
226 const char *file = NULL; 234 const char *file = NULL;
227 int want_enforcement = 0; 235 int want_enforcement = 0;
@@ -282,6 +290,9 @@ int main(int argc, char** argv)
282 case 'l': 290 case 'l':
283 test_loop = 1; 291 test_loop = 1;
284 break; 292 break;
293 case 'B':
294 background_loop = 1;
295 break;
285 case 'o': 296 case 'o':
286 column = atoi(optarg); 297 column = atoi(optarg);
287 break; 298 break;
@@ -317,6 +328,9 @@ int main(int argc, char** argv)
317 case 'v': 328 case 'v':
318 verbose = 1; 329 verbose = 1;
319 break; 330 break;
331 case 'h':
332 usage(NULL);
333 break;
320 case 'i': 334 case 'i':
321 report_interrupts = 1; 335 report_interrupts = 1;
322 break; 336 break;
@@ -330,7 +344,7 @@ int main(int argc, char** argv)
330 } 344 }
331 } 345 }
332 346
333 if(nr_of_pages) { 347 if (nr_of_pages) {
334 page_size = getpagesize(); 348 page_size = getpagesize();
335 rss = page_size * nr_of_pages; 349 rss = page_size * nr_of_pages;
336 base = mmap(NULL, rss, PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); 350 base = mmap(NULL, rss, PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
@@ -350,12 +364,22 @@ int main(int argc, char** argv)
350 memset(base + (idx * page_size), 1, page_size); 364 memset(base + (idx * page_size), 1, page_size);
351 } 365 }
352 366
367 srand(getpid());
368
353 if (test_loop) { 369 if (test_loop) {
354 debug_delay_loop(); 370 debug_delay_loop();
355 return 0; 371 return 0;
356 } 372 }
357 373
358 srand(getpid()); 374 if (background_loop) {
375 while (1) {
376 if (nr_of_pages)
377 loop_once_with_mem();
378 else
379 loop_once();
380 }
381 return 0;
382 }
359 383
360 if (file) { 384 if (file) {
361 get_exec_times(file, column, &num_jobs, &exec_times); 385 get_exec_times(file, column, &num_jobs, &exec_times);