Attachment 'liblitmus-rtas17.patch'
Download 1 diff --git a/.gitignore b/.gitignore
2 index a52500b..f42c50a 100644
3 --- a/.gitignore
4 +++ b/.gitignore
5 @@ -23,6 +23,10 @@ showst
6 rtspin
7 cycles
8 measure_syscall
9 +mc2spin
10 +mc2mem_stc
11 +mc2mem_ssh
12 +mc2mem
13
14 # build system files
15 .config
16 diff --git a/Makefile b/Makefile
17 index 4742fd2..ee2a9b2 100644
18 --- a/Makefile
19 +++ b/Makefile
20 @@ -19,7 +19,7 @@ LITMUS_KERNEL ?= ../litmus-rt
21 # Internal configuration.
22
23 # compiler flags
24 -flags-debug = -O2 -Wall -Werror -g -Wdeclaration-after-statement
25 +flags-debug = -O2 -Wall -g -Wdeclaration-after-statement
26 flags-api = -D_XOPEN_SOURCE=600 -D_GNU_SOURCE
27
28 # architecture-specific flags
29 @@ -73,7 +73,7 @@ AR := ${CROSS_COMPILE}${AR}
30
31 all = lib ${rt-apps}
32 rt-apps = cycles base_task rt_launch rtspin release_ts measure_syscall \
33 - base_mt_task uncache runtests
34 + base_mt_task uncache runtests mc2mem_stc mc2mem_ssh mc2spin
35
36 .PHONY: all lib clean dump-config TAGS tags cscope help doc
37
38 @@ -234,6 +234,14 @@ obj-release_ts = release_ts.o
39 obj-measure_syscall = null_call.o
40 lib-measure_syscall = -lm
41
42 +obj-mc2mem_stc = mc2mem.o common.o
43 +lib-mc2mem_stc = -lrt -static
44 +
45 +obj-mc2mem_ssh = mc2mem.o common.o
46 +lib-mc2mem_ssh = -lrt
47 +
48 +obj-mc2spin = mc2spin.o common.o
49 +lib-mc2spin = -lrt
50 # ##############################################################################
51 # Build everything that depends on liblitmus.
52
53 diff --git a/bin/mc2mem.c b/bin/mc2mem.c
54 new file mode 100644
55 index 0000000..2fba878
56 --- /dev/null
57 +++ b/bin/mc2mem.c
58 @@ -0,0 +1,304 @@
59 +#include <sys/time.h>
60 +#include <sys/mman.h>
61 +
62 +#include <stdio.h>
63 +#include <stdlib.h>
64 +#include <unistd.h>
65 +#include <time.h>
66 +#include <string.h>
67 +#include <assert.h>
68 +#include <limits.h>
69 +#include <fcntl.h>
70 +#include <math.h>
71 +
72 +#include "litmus.h"
73 +#include "common.h"
74 +#include "cache_common.h"
75 +
76 +#define PAGE_SIZE (4096)
77 +#define CACHELINE_SIZE 32
78 +#define INTS_IN_CACHELINE (CACHELINE_SIZE/sizeof(int))
79 +#define CACHELINES_IN_1KB (1024 / sizeof(cacheline_t))
80 +#define INTS_IN_1KB (1024 / sizeof(int))
81 +#define INTS_IN_CACHELINE (CACHELINE_SIZE/sizeof(int))
82 +
83 +static int loops = 100;
84 +static cacheline_t* arena = NULL;
85 +static int verbose = 0;
86 +
87 +#define UNCACHE_DEV "/dev/litmus/uncache"
88 +
89 +/* Random walk around the arena in cacheline-sized chunks.
90 + Cacheline-sized chucks ensures the same utilization of each
91 + hit line as sequential read. (Otherwise, our utilization
92 + would only be 1/INTS_IN_CACHELINE.) */
93 +static int random_walk(cacheline_t *mem, int wss, int write_cycle)
94 +{
95 + /* a random cycle among the cache lines was set up by init_arena(). */
96 + int sum, i, next;
97 +
98 + int numlines = wss * CACHELINES_IN_1KB;
99 +
100 + sum = 0;
101 +
102 + /* contents of arena is structured s.t. offsets are all
103 + w.r.t. to start of arena, so compute the initial offset */
104 + next = mem - arena;
105 +
106 + if (write_cycle == 0) {
107 + for (i = 0; i < numlines; i++) {
108 + /* every element in the cacheline has the same value */
109 + next = arena[next].line[0];
110 + sum += next;
111 + }
112 + }
113 +
114 + else {
115 + int w, which_line;
116 + for (i = 0, w = 0; i < numlines; i++) {
117 + which_line = next;
118 + next = arena[next].line[0];
119 + if((w % write_cycle) != (write_cycle - 1)) {
120 + sum += next;
121 + }
122 + else {
123 + ((volatile cacheline_t*)arena)[which_line].line[0] = next;
124 + }
125 + }
126 + }
127 + return sum;
128 +}
129 +
130 +static cacheline_t* random_start(int wss)
131 +{
132 + return arena + randrange(0, ((wss * 1024)/sizeof(cacheline_t)));
133 +}
134 +
135 +static volatile int dont_optimize_me = 0;
136 +
137 +static void usage(char *error) {
138 + fprintf(stderr, "Error: %s\n", error);
139 + fprintf(stderr,
140 + "Usage:\n"
141 + " rt_spin [COMMON-OPTS] WCET PERIOD DURATION\n"
142 + " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n"
143 + " rt_spin -l\n"
144 + "\n"
145 + "COMMON-OPTS = [-w] [-s SCALE]\n"
146 + " [-p PARTITION/CLUSTER [-z CLUSTER SIZE]] [-m CRITICALITY LEVEL]\n"
147 + " [-k WSS] [-l LOOPS] [-b BUDGET]\n"
148 + "\n"
149 + "WCET and PERIOD are milliseconds, DURATION is seconds.\n");
150 + exit(EXIT_FAILURE);
151 +}
152 +
153 +static int loop_once(int wss)
154 +{
155 + cacheline_t *mem;
156 + int temp;
157 +
158 + mem = random_start(wss);
159 + temp = random_walk(mem, wss, 0);
160 +
161 + dont_optimize_me = temp;
162 +
163 + return dont_optimize_me;
164 +}
165 +
166 +static int job(int wss, double exec_time, double program_end)
167 +{
168 + if (wctime() > program_end)
169 + return 0;
170 + else {
171 + register unsigned int iter = 0;
172 + register cycles_t t;
173 + t = get_cycles();
174 + while(iter++ < loops) {
175 + loop_once(wss);
176 + }
177 + t = get_cycles() - t;
178 + if (verbose)
179 + printf("%ld cycles\n", t);
180 + sleep_next_period();
181 + return 1;
182 + }
183 +}
184 +
185 +#define OPTSTR "p:wl:m:i:b:k:v"
186 +int main(int argc, char** argv)
187 +{
188 + int ret;
189 + lt_t wcet, period, budget;
190 + double wcet_ms, period_ms, budget_ms;
191 + unsigned int priority = LITMUS_NO_PRIORITY;
192 + int migrate = 0;
193 + int cluster = 0;
194 + int opt;
195 + int wait = 0;
196 + double duration = 0, start = 0;
197 + struct rt_task param;
198 + struct mc2_task mc2_param;
199 + struct reservation_config config;
200 + int res_type = PERIODIC_POLLING;
201 + size_t arena_sz;
202 + int wss = 0;
203 +
204 + /* default for reservation */
205 + config.id = 0;
206 + config.priority = LITMUS_NO_PRIORITY; /* use EDF by default */
207 + config.cpu = -1;
208 +
209 + mc2_param.crit = CRIT_LEVEL_C;
210 +
211 + budget_ms = 1000;
212 +
213 + while ((opt = getopt(argc, argv, OPTSTR)) != -1) {
214 + switch (opt) {
215 + case 'w':
216 + wait = 1;
217 + break;
218 + case 'p':
219 + cluster = atoi(optarg);
220 + migrate = 1;
221 + config.cpu = cluster;
222 + break;
223 + case 'l':
224 + loops = atoi(optarg);
225 + break;
226 + case 'k':
227 + wss = atoi(optarg);
228 + break;
229 + case 'm':
230 + mc2_param.crit = atoi(optarg);
231 + if ((mc2_param.crit >= CRIT_LEVEL_A) && (mc2_param.crit <= CRIT_LEVEL_C)) {
232 + res_type = PERIODIC_POLLING;
233 + }
234 + else
235 + usage("Invalid criticality level.");
236 + break;
237 + case 'b':
238 + budget_ms = atof(optarg);
239 + break;
240 + case 'i':
241 + config.priority = atoi(optarg);
242 + break;
243 + case 'v':
244 + verbose = 1;
245 + break;
246 + case ':':
247 + usage("Argument missing.");
248 + break;
249 + case '?':
250 + default:
251 + usage("Bad argument.");
252 + break;
253 + }
254 + }
255 + srand(getpid());
256 +
257 + /*
258 + * We need three parameters
259 + */
260 + if (argc - optind < 3)
261 + usage("Arguments missing.");
262 +
263 + wcet_ms = atof(argv[optind + 0]);
264 + period_ms = atof(argv[optind + 1]);
265 +
266 + wcet = ms2ns(wcet_ms);
267 + period = ms2ns(period_ms);
268 + budget = ms2ns(budget_ms);
269 + if (wcet <= 0)
270 + usage("The worst-case execution time must be a "
271 + "positive number.");
272 + if (period <= 0)
273 + usage("The period must be a positive number.");
274 + if (wcet > period) {
275 + usage("The worst-case execution time must not "
276 + "exceed the period.");
277 + }
278 + if (wss == 0) {
279 + usage("You need to specify a WSS (-k option).");
280 + }
281 +
282 + duration = atof(argv[optind + 2]);
283 +
284 + if (migrate) {
285 + ret = be_migrate_to_domain(cluster);
286 + if (ret < 0)
287 + bail_out("could not migrate to target partition or cluster.");
288 + }
289 +
290 + /* reservation config */
291 + config.id = gettid();
292 + config.polling_params.budget = budget;
293 + config.polling_params.period = period;
294 + config.polling_params.offset = 0;
295 + config.polling_params.relative_deadline = 0;
296 +
297 + if (config.polling_params.budget > config.polling_params.period) {
298 + usage("The budget must not exceed the period.");
299 + }
300 +
301 + /* create a reservation */
302 + ret = reservation_create(res_type, &config);
303 + if (ret < 0) {
304 + bail_out("failed to create reservation.");
305 + }
306 +
307 + init_rt_task_param(¶m);
308 + param.exec_cost = wcet;
309 + param.period = period;
310 + param.priority = priority;
311 + param.cls = RT_CLASS_HARD;
312 + param.release_policy = TASK_PERIODIC;
313 + param.budget_policy = NO_ENFORCEMENT;
314 + if (migrate) {
315 + param.cpu = gettid();
316 + }
317 + ret = set_rt_task_param(gettid(), ¶m);
318 + if (ret < 0)
319 + bail_out("could not setup rt task params");
320 +
321 + mc2_param.res_id = gettid();
322 + ret = set_mc2_task_param(gettid(), &mc2_param);
323 + if (ret < 0)
324 + bail_out("could not setup mc2 task params");
325 +
326 + arena_sz = wss*1024;
327 + arena = alloc_arena(arena_sz, 0, 0);
328 + init_arena(arena, arena_sz);
329 +
330 + lock_memory();
331 +
332 + if (mc2_param.crit == CRIT_LEVEL_C)
333 + set_page_color(-1);
334 + else
335 + set_page_color(config.cpu);
336 +
337 + ret = init_litmus();
338 + if (ret != 0)
339 + bail_out("init_litmus() failed\n");
340 +
341 + start = wctime();
342 + ret = task_mode(LITMUS_RT_TASK);
343 + if (ret != 0)
344 + bail_out("could not become RT task");
345 +
346 + if (wait) {
347 + ret = wait_for_ts_release();
348 + if (ret != 0)
349 + bail_out("wait_for_ts_release()");
350 + start = wctime();
351 + }
352 +
353 + while (job(wss, wcet_ms * 0.001, start + duration)) {};
354 +
355 + ret = task_mode(BACKGROUND_TASK);
356 + if (ret != 0)
357 + bail_out("could not become regular task (huh?)");
358 +
359 + reservation_destroy(gettid(), config.cpu);
360 + dealloc_arena(arena, arena_sz);
361 + return 0;
362 +}
363 diff --git a/bin/mc2spin.c b/bin/mc2spin.c
364 new file mode 100644
365 index 0000000..e41c62c
366 --- /dev/null
367 +++ b/bin/mc2spin.c
368 @@ -0,0 +1,250 @@
369 +#include <sys/time.h>
370 +#include <sys/mman.h>
371 +
372 +#include <stdio.h>
373 +#include <stdlib.h>
374 +#include <unistd.h>
375 +#include <time.h>
376 +#include <string.h>
377 +#include <assert.h>
378 +#include <limits.h>
379 +#include <fcntl.h>
380 +#include <math.h>
381 +
382 +#include "litmus.h"
383 +#include "common.h"
384 +
385 +#define PAGE_SIZE (4096)
386 +
387 +static int verbose = 0;
388 +
389 +#define UNCACHE_DEV "/dev/litmus/uncache"
390 +
391 +static void usage(char *error) {
392 + fprintf(stderr, "Error: %s\n", error);
393 + fprintf(stderr,
394 + "Usage:\n"
395 + " rt_spin [COMMON-OPTS] WCET PERIOD DURATION\n"
396 + " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n"
397 + " rt_spin -l\n"
398 + "\n"
399 + "COMMON-OPTS = [-w] [-s SCALE]\n"
400 + " [-p PARTITION/CLUSTER [-z CLUSTER SIZE]] [-m CRITICALITY LEVEL]\n"
401 + " [-k WSS] [-l LOOPS] [-b BUDGET]\n"
402 + "\n"
403 + "WCET and PERIOD are milliseconds, DURATION is seconds.\n");
404 + exit(EXIT_FAILURE);
405 +}
406 +
407 +#define NUMS 4096
408 +static int num[NUMS];
409 +static char* progname;
410 +
411 +static int loop_once(void)
412 +{
413 + int i, j = 0;
414 + for (i = 0; i < NUMS; i++)
415 + j += num[i]++;
416 + return j;
417 +}
418 +
419 +static int loop_for(double exec_time, double emergency_exit)
420 +{
421 + double last_loop = 0, loop_start;
422 + int tmp = 0;
423 +
424 + double start = cputime();
425 + double now = cputime();
426 +
427 + while (now + last_loop < start + exec_time) {
428 + loop_start = now;
429 + tmp += loop_once();
430 + now = cputime();
431 + last_loop = now - loop_start;
432 + if (emergency_exit && wctime() > emergency_exit) {
433 + /* Oops --- this should only be possible if the execution time tracking
434 + * is broken in the LITMUS^RT kernel. */
435 + fprintf(stderr, "!!! rtspin/%d emergency exit!\n", getpid());
436 + fprintf(stderr, "Something is seriously wrong! Do not ignore this.\n");
437 + break;
438 + }
439 + }
440 +
441 + return tmp;
442 +}
443 +
444 +static int job(double exec_time, double program_end)
445 +{
446 + if (wctime() > program_end)
447 + return 0;
448 + else {
449 + loop_for(exec_time, program_end + 1);
450 + sleep_next_period();
451 + return 1;
452 + }
453 +}
454 +
455 +#define OPTSTR "p:wm:i:v"
456 +int main(int argc, char** argv)
457 +{
458 + int ret;
459 + lt_t wcet, period, budget;
460 + double wcet_ms, period_ms;
461 + unsigned int priority = LITMUS_NO_PRIORITY;
462 + int migrate = 0;
463 + int cluster = 0;
464 + int opt;
465 + int wait = 0;
466 + double duration = 0, start = 0;
467 + struct rt_task param;
468 + struct mc2_task mc2_param;
469 + struct reservation_config config;
470 + int res_type = PERIODIC_POLLING;
471 +
472 + /* default for reservation */
473 + config.id = 0;
474 + config.priority = LITMUS_NO_PRIORITY; /* use EDF by default */
475 + config.cpu = -1;
476 +
477 + mc2_param.crit = CRIT_LEVEL_C;
478 +
479 + progname = argv[0];
480 +
481 + while ((opt = getopt(argc, argv, OPTSTR)) != -1) {
482 + switch (opt) {
483 + case 'w':
484 + wait = 1;
485 + break;
486 + case 'p':
487 + cluster = atoi(optarg);
488 + migrate = 1;
489 + config.cpu = cluster;
490 + break;
491 + case 'm':
492 + mc2_param.crit = atoi(optarg);
493 + if ((mc2_param.crit >= CRIT_LEVEL_A) && (mc2_param.crit <= CRIT_LEVEL_C)) {
494 + res_type = PERIODIC_POLLING;
495 + }
496 + else
497 + usage("Invalid criticality level.");
498 + break;
499 + case 'i':
500 + config.priority = atoi(optarg);
501 + break;
502 + case 'v':
503 + verbose = 1;
504 + break;
505 + case ':':
506 + usage("Argument missing.");
507 + break;
508 + case '?':
509 + default:
510 + usage("Bad argument.");
511 + break;
512 + }
513 + }
514 + srand(getpid());
515 +
516 + /*
517 + * We need three parameters
518 + */
519 + if (argc - optind < 3)
520 + usage("Arguments missing.");
521 +
522 + wcet_ms = atof(argv[optind + 0]);
523 + period_ms = atof(argv[optind + 1]);
524 +
525 + wcet = ms2ns(wcet_ms);
526 + period = ms2ns(period_ms);
527 + budget = ms2ns(wcet_ms+1);
528 + if (wcet <= 0)
529 + usage("The worst-case execution time must be a "
530 + "positive number.");
531 + if (period <= 0)
532 + usage("The period must be a positive number.");
533 + if (wcet > period) {
534 + usage("The worst-case execution time must not "
535 + "exceed the period.");
536 + }
537 +
538 + duration = atof(argv[optind + 2]);
539 +
540 + if (mc2_param.crit == CRIT_LEVEL_C) {
541 + migrate = 0;
542 + config.cpu = -1;
543 + }
544 +
545 + if (migrate) {
546 + ret = be_migrate_to_domain(cluster);
547 + if (ret < 0)
548 + bail_out("could not migrate to target partition or cluster.");
549 + }
550 +
551 + /* reservation config */
552 + config.id = gettid();
553 + config.polling_params.budget = budget;
554 + config.polling_params.period = period;
555 + config.polling_params.offset = 0;
556 + config.polling_params.relative_deadline = 0;
557 +
558 + if (config.polling_params.budget > config.polling_params.period) {
559 + usage("The budget must not exceed the period.");
560 + }
561 +
562 + /* create a reservation */
563 + ret = reservation_create(res_type, &config);
564 + if (ret < 0) {
565 + bail_out("failed to create reservation.");
566 + }
567 +
568 + init_rt_task_param(¶m);
569 + param.exec_cost = wcet;
570 + param.period = period;
571 + param.priority = priority;
572 + param.cls = RT_CLASS_HARD;
573 + param.release_policy = TASK_PERIODIC;
574 + param.budget_policy = NO_ENFORCEMENT;
575 + if (migrate) {
576 + param.cpu = gettid();
577 + }
578 + ret = set_rt_task_param(gettid(), ¶m);
579 + if (ret < 0)
580 + bail_out("could not setup rt task params");
581 +
582 + mc2_param.res_id = gettid();
583 + ret = set_mc2_task_param(gettid(), &mc2_param);
584 + if (ret < 0)
585 + bail_out("could not setup mc2 task params");
586 +
587 + ret = init_litmus();
588 + if (ret != 0)
589 + bail_out("init_litmus() failed\n");
590 +
591 + start = wctime();
592 +
593 + ret = task_mode(LITMUS_RT_TASK);
594 + if (ret != 0)
595 + bail_out("could not become RT task");
596 +
597 + if (wait) {
598 + ret = wait_for_ts_release();
599 + if (ret != 0)
600 + bail_out("wait_for_ts_release()");
601 + start = wctime();
602 + }
603 +
604 + do {
605 + if (verbose) {
606 + printf("rtspin:%u @ %.4fms\n", gettid(),
607 + (wctime() - start) * 1000);
608 + }
609 + } while (job(wcet_ms * 0.001, start + duration));
610 +
611 + ret = task_mode(BACKGROUND_TASK);
612 + if (ret != 0)
613 + bail_out("could not become regular task (huh?)");
614 +
615 + reservation_destroy(gettid(), config.cpu);
616 + return 0;
617 +}
618 +
619 diff --git a/include/cache_common.h b/include/cache_common.h
620 new file mode 100644
621 index 0000000..8239233
622 --- /dev/null
623 +++ b/include/cache_common.h
624 @@ -0,0 +1,140 @@
625 +#ifndef __CACHE_COMMON_H__
626 +#define __CACHE_COMMON_H__
627 +
628 +#include <stdio.h>
629 +#include <stdlib.h>
630 +#include <time.h>
631 +#include <string.h>
632 +#include <assert.h>
633 +
634 +#include <signal.h>
635 +#include <sys/mman.h>
636 +#include <sys/types.h>
637 +#include <sys/stat.h>
638 +#include <fcntl.h>
639 +#include <unistd.h>
640 +
641 +#include <sys/io.h>
642 +#include <sys/utsname.h>
643 +
644 +#include <sched.h>
645 +#include <sys/time.h>
646 +#include <sys/resource.h>
647 +
648 +#include "litmus.h"
649 +#include "asm/cycles.h"
650 +
651 +#if defined(__i386__) || defined(__x86_64__)
652 +#include "asm/irq.h"
653 +#endif
654 +
655 +
656 +#define UNCACHE_DEV "/dev/litmus/uncache"
657 +
658 +static void die(char *error)
659 +{
660 + fprintf(stderr, "Error: %s (errno: %m)\n",
661 + error);
662 + exit(1);
663 +}
664 +
665 +static int lock_memory(void)
666 +{
667 + return mlockall(MCL_CURRENT | MCL_FUTURE);
668 +}
669 +
670 +/* define CACHELINE_SIZE if not provided by compiler args */
671 +#ifndef CACHELINE_SIZE
672 +#if defined(__i386__) || defined(__x86_64__)
673 +/* recent intel cpus */
674 +#define CACHELINE_SIZE 64
675 +#elif defined(__arm__)
676 +/* at least with Cortex-A9 cpus ("8 words") */
677 +#define CACHELINE_SIZE 32
678 +#else
679 +#error "Could not determine cacheline size!"
680 +#endif
681 +#endif
682 +
683 +#define INTS_IN_CACHELINE (CACHELINE_SIZE/sizeof(int))
684 +typedef struct cacheline
685 +{
686 + int line[INTS_IN_CACHELINE];
687 +} __attribute__((aligned(CACHELINE_SIZE))) cacheline_t;
688 +
689 +#define CACHELINES_IN_1KB (1024 / sizeof(cacheline_t))
690 +
691 +
692 +static cacheline_t* alloc_arena(size_t size, int use_huge_pages, int use_uncache_pages)
693 +{
694 + int flags = MAP_PRIVATE | MAP_POPULATE;
695 + cacheline_t* arena = NULL;
696 + int fd;
697 +
698 + if(use_huge_pages)
699 + flags |= MAP_HUGETLB;
700 +
701 + if(use_uncache_pages) {
702 + fd = open(UNCACHE_DEV, O_RDWR);
703 + if (fd == -1)
704 + die("Failed to open uncache device. Are you running the LITMUS^RT kernel?");
705 + }
706 + else {
707 + fd = -1;
708 + flags |= MAP_ANONYMOUS;
709 + }
710 +
711 + arena = mmap(0, size, PROT_READ | PROT_WRITE, flags, fd, 0);
712 +
713 + if(use_uncache_pages)
714 + close(fd);
715 +
716 + assert(arena);
717 +
718 + return arena;
719 +}
720 +
721 +static void dealloc_arena(cacheline_t* arena, size_t size)
722 +{
723 + int ret = munmap((void*)arena, size);
724 + if(ret != 0)
725 + die("munmap() error");
726 +}
727 +
728 +static int randrange(int min, int max)
729 +{
730 + /* generate a random number on the range [min, max) w/o skew */
731 + int limit = max - min;
732 + int devisor = RAND_MAX/limit;
733 + int retval;
734 +
735 + do {
736 + retval = rand() / devisor;
737 + } while(retval == limit);
738 + retval += min;
739 +
740 + return retval;
741 +}
742 +
743 +static void init_arena(cacheline_t* arena, size_t size)
744 +{
745 + int i;
746 + size_t num_arena_elem = size / sizeof(cacheline_t);
747 +
748 + /* Generate a cycle among the cache lines using Sattolo's algorithm.
749 + Every int in the cache line points to the same cache line.
750 + Note: Sequential walk doesn't care about these values. */
751 + for (i = 0; i < num_arena_elem; i++) {
752 + int j;
753 + for(j = 0; j < INTS_IN_CACHELINE; ++j)
754 + arena[i].line[j] = i;
755 + }
756 + while(1 < i--) {
757 + int j = randrange(0, i);
758 + cacheline_t temp = arena[j];
759 + arena[j] = arena[i];
760 + arena[i] = temp;
761 + }
762 +}
763 +
764 +#endif
765 diff --git a/include/litmus.h b/include/litmus.h
766 index b9dbdb5..4b97b87 100644
767 --- a/include/litmus.h
768 +++ b/include/litmus.h
769 @@ -40,6 +40,8 @@ extern "C" {
770
771 #include "migration.h"
772
773 +#include "litmus/mc2_common.h"
774 +
775 /**
776 * @private
777 * The numeric ID of the LITMUS^RT scheduling class.
778 @@ -146,6 +148,12 @@ int sporadic_clustered(lt_t e_ns, lt_t p_ns, int cluster);
779 /** Convert microseconds to nanoseconds
780 * @param us Time units in microseconds */
781 #define us2ns(us) ((us)*1000LL)
782 +#define ns2s(ns) ((ns)/1000000000LL)
783 +#define ns2ms(ns) ((ns)/1000000LL)
784 +#define ns2us(ns) ((ns)/1000LL)
785 +#define us2ms(us) ((us)/1000LL)
786 +#define us2s(us) ((us)/1000000LL)
787 +#define ms2s(ms) ((ms)/1000LL)
788
789 /**
790 * Locking protocols for allocated shared objects
791 @@ -416,6 +424,18 @@ int null_call(cycles_t *timestamp);
792 */
793 struct control_page* get_ctrl_page(void);
794
795 +int reservation_create(int rtype, void *config);
796 +
797 +int reservation_destroy(unsigned int reservation_id, int cpu);
798 +
799 +int set_mc2_task_param(pid_t pid, struct mc2_task* param);
800 +
801 +int set_page_color(int cpu);
802 +
803 +int test_call(unsigned int param);
804 +
805 +typedef struct cacheline cacheline_t;
806 +
807 #ifdef __cplusplus
808 }
809 #endif
810 diff --git a/src/syscalls.c b/src/syscalls.c
811 index c68f15b..ab064ad 100644
812 --- a/src/syscalls.c
813 +++ b/src/syscalls.c
814 @@ -86,3 +86,28 @@ int null_call(cycles_t *timestamp)
815 {
816 return syscall(__NR_null_call, timestamp);
817 }
818 +
819 +int reservation_create(int rtype, void *config)
820 +{
821 + return syscall(__NR_reservation_create, rtype, config);
822 +}
823 +
824 +int reservation_destroy(unsigned int reservation_id, int cpu)
825 +{
826 + return syscall(__NR_reservation_destroy, reservation_id, cpu);
827 +}
828 +
829 +int set_mc2_task_param(pid_t pid, struct mc2_task *param)
830 +{
831 + return syscall(__NR_set_mc2_task_param, pid, param);
832 +}
833 +
834 +int set_page_color(int cpu)
835 +{
836 + return syscall(__NR_set_page_color, cpu);
837 +}
838 +
839 +int test_call(unsigned int param)
840 +{
841 + return syscall(__NR_test_call, param);
842 +}
843
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.