diff options
-rw-r--r-- | Makefile | 23 | ||||
-rw-r--r-- | bin/hrt.c | 78 | ||||
-rw-r--r-- | bin/iotest.c | 74 | ||||
-rw-r--r-- | bin/rt_launch.c | 82 | ||||
-rw-r--r-- | bin/set_rt_mode.c | 46 | ||||
-rw-r--r-- | bin/show_scheduler.c | 10 | ||||
-rw-r--r-- | bin/stdump.c | 22 | ||||
-rw-r--r-- | bin/timeout.c | 36 | ||||
-rw-r--r-- | include/adaptive.h | 38 | ||||
-rw-r--r-- | include/edf-hsb.h | 10 | ||||
-rw-r--r-- | include/litmus.h | 57 | ||||
-rw-r--r-- | include/sched_trace.h | 21 | ||||
-rw-r--r-- | src/adaptive.c | 48 | ||||
-rw-r--r-- | src/edf-hsb.c | 48 | ||||
-rw-r--r-- | src/litmus.c | 37 | ||||
-rw-r--r-- | src/sched_trace.c | 1 | ||||
-rw-r--r-- | src/syscalls.c | 7 |
17 files changed, 20 insertions, 618 deletions
@@ -3,9 +3,9 @@ CPPFLAGS=-Wall -g | |||
3 | 3 | ||
4 | LIBS= ./liblitmus.a | 4 | LIBS= ./liblitmus.a |
5 | 5 | ||
6 | LIB_OBJ= litmus.o syscalls.o sched_trace.o adaptive.o edf-hsb.o task.o kernel_iface.o | 6 | LIB_OBJ= litmus.o syscalls.o sched_trace.o task.o kernel_iface.o |
7 | 7 | ||
8 | TARGETS = showsched iotest set_rt_mode run timeout rt_launch edfhsb liblitmus.a \ | 8 | TARGETS = run rt_launch liblitmus.a \ |
9 | wait_test np_test stdump mode_test base_task base_mt_task | 9 | wait_test np_test stdump mode_test base_task base_mt_task |
10 | 10 | ||
11 | vpath %.h include/ | 11 | vpath %.h include/ |
@@ -30,30 +30,15 @@ mode_test: mode_test.o litmus.h liblitmus.a | |||
30 | np_test: np_test.o litmus.h liblitmus.a | 30 | np_test: np_test.o litmus.h liblitmus.a |
31 | cc -static -o np_test np_test.o ${LIBS} | 31 | cc -static -o np_test np_test.o ${LIBS} |
32 | 32 | ||
33 | iotest: iotest.o litmus.h liblitmus.a | 33 | run: run.o ${LIBS} |
34 | cc -static -o iotest iotest.o ${LIBS} | ||
35 | |||
36 | run: run.o | ||
37 | cc -o run run.o ${LIBS} | 34 | cc -o run run.o ${LIBS} |
38 | 35 | ||
39 | set_rt_mode: liblitmus.a set_rt_mode.o | ||
40 | cc -o set_rt_mode set_rt_mode.o ${LIBS} | ||
41 | |||
42 | showsched: show_scheduler.o liblitmus.a litmus.h | ||
43 | cc -o showsched show_scheduler.o ${LIBS} | ||
44 | |||
45 | timeout: liblitmus.a timeout.o litmus.h | ||
46 | cc -static -o timeout timeout.o ${LIBS} | ||
47 | |||
48 | rt_launch: liblitmus.a litmus.h rt_launch.o | 36 | rt_launch: liblitmus.a litmus.h rt_launch.o |
49 | cc -static -o rt_launch rt_launch.o ${LIBS} | 37 | cc -static -o rt_launch rt_launch.o ${LIBS} |
50 | 38 | ||
51 | edfhsb: liblitmus.a edf-hsb.o litmus.h edf-hsb.h hrt.o | ||
52 | cc -o edfhsb hrt.o edf-hsb.o ${LIBS} | ||
53 | |||
54 | stdump: liblitmus.a litmus.h sched_trace.h stdump.o | 39 | stdump: liblitmus.a litmus.h sched_trace.h stdump.o |
55 | cc -o stdump stdump.o ${LIBS} | 40 | cc -o stdump stdump.o ${LIBS} |
56 | 41 | ||
57 | liblitmus.a: ${LIB_OBJ} adaptive.h litmus.h edf-hsb.h | 42 | liblitmus.a: ${LIB_OBJ} litmus.h |
58 | ${AR} rcs liblitmus.a ${LIB_OBJ} | 43 | ${AR} rcs liblitmus.a ${LIB_OBJ} |
59 | 44 | ||
diff --git a/bin/hrt.c b/bin/hrt.c deleted file mode 100644 index 224293c..0000000 --- a/bin/hrt.c +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | |||
5 | #include "edf-hsb.h" | ||
6 | |||
7 | |||
8 | void usage(char *name) | ||
9 | { | ||
10 | fprintf(stderr, | ||
11 | "EDF-HSB server setup utility\n" | ||
12 | "Usage: %s hrt show <#cpu>\n" | ||
13 | " %s hrt set <#cpu> <wcet> <period>\n" | ||
14 | " %s be create <wcet> <period>\n", | ||
15 | name, name, name); | ||
16 | exit(1); | ||
17 | } | ||
18 | |||
19 | |||
20 | int hrt(int argc, char** argv) | ||
21 | { | ||
22 | int wcet, period, cpu; | ||
23 | |||
24 | if (argc == 2 && !strcmp(argv[0], "show")) { | ||
25 | cpu = atoi(argv[1]); | ||
26 | if (!get_hrt(cpu, &wcet, &period)) | ||
27 | printf("HRT/%d = (%d, %d)\n", cpu, wcet, period); | ||
28 | else | ||
29 | perror("cannot read HRT settings"); | ||
30 | } else if (argc == 4 && !strcmp(argv[0], "set")) { | ||
31 | cpu = atoi(argv[1]); | ||
32 | wcet = atoi(argv[2]); | ||
33 | period = atoi(argv[3]); | ||
34 | printf("Setting HRT/%d to (%d, %d)", cpu, wcet, period); | ||
35 | if (!set_hrt(cpu, wcet, period)) | ||
36 | printf(" OK.\n"); | ||
37 | else { | ||
38 | printf("\n"); | ||
39 | perror("cannot write HRT settings"); | ||
40 | } | ||
41 | } else | ||
42 | return 1; | ||
43 | |||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | int be(int argc, char** argv) | ||
48 | { | ||
49 | int wcet, period; | ||
50 | if (argc == 3 && !strcmp(argv[0], "create")) { | ||
51 | wcet = atoi(argv[1]); | ||
52 | period = atoi(argv[2]); | ||
53 | printf("Creating BE with (%d, %d)", wcet, period); | ||
54 | if (!create_be(wcet, period)) | ||
55 | printf(" OK.\n"); | ||
56 | else { | ||
57 | printf("\n"); | ||
58 | perror("cannot create BE server"); | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | else | ||
63 | return 1; | ||
64 | } | ||
65 | |||
66 | int main(int argc, char** argv) | ||
67 | { | ||
68 | int ret = 1; | ||
69 | if (argc > 1) { | ||
70 | if (!strcmp(argv[1], "hrt")) | ||
71 | ret = hrt(argc - 2, argv + 2); | ||
72 | else if (!strcmp(argv[1], "be")) | ||
73 | ret = be(argc - 2, argv + 2); | ||
74 | } | ||
75 | if (ret) | ||
76 | usage(argv[0]); | ||
77 | return ret; | ||
78 | } | ||
diff --git a/bin/iotest.c b/bin/iotest.c deleted file mode 100644 index ac07e74..0000000 --- a/bin/iotest.c +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <signal.h> | ||
4 | #include <unistd.h> | ||
5 | #include <sys/time.h> | ||
6 | #include <sys/wait.h> | ||
7 | |||
8 | #include "litmus.h" | ||
9 | |||
10 | #define US_PER_MS 1000 | ||
11 | |||
12 | int iotest(void *nil) { | ||
13 | int id = getpid(); | ||
14 | FILE* file; | ||
15 | char str[255]; | ||
16 | unsigned long last = 0; | ||
17 | struct timeval time; | ||
18 | |||
19 | printf("I'am real time task %d doing IO!\n", id); | ||
20 | snprintf(str, sizeof(str), "rt-io-%d.txt", id); | ||
21 | file = fopen(str, "w"); | ||
22 | if (!file) { | ||
23 | perror("could not open file for output"); | ||
24 | exit(1); | ||
25 | } | ||
26 | while (1) { | ||
27 | gettimeofday(&time, NULL); | ||
28 | if (time.tv_usec - last > US_PER_MS) { | ||
29 | fprintf(file, "ran at %lus %lums\n", time.tv_sec, time.tv_usec / US_PER_MS); | ||
30 | last = time.tv_usec; | ||
31 | } | ||
32 | fflush(file); | ||
33 | } | ||
34 | return id; | ||
35 | } | ||
36 | |||
37 | #define NUMTASKS 4 | ||
38 | |||
39 | int main(int argc, char** argv) | ||
40 | { | ||
41 | int rt_task[NUMTASKS]; | ||
42 | int i; | ||
43 | int ret, pid; | ||
44 | |||
45 | for (i = 0; i < NUMTASKS; i++) { | ||
46 | /* func arg cpu wcet period */ | ||
47 | rt_task[i] = create_rt_task(iotest, NULL, 0, 25, 100); | ||
48 | if (rt_task[i] < 0) { | ||
49 | perror("Could not create rt child process"); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | sync(); | ||
54 | sync(); | ||
55 | |||
56 | printf(":: Starting real-time mode.\n"); | ||
57 | set_rt_mode(MODE_RT_RUN); | ||
58 | |||
59 | printf(":: Sleeping...\n"); | ||
60 | sleep(120); | ||
61 | |||
62 | printf("Killing real-time tasks.\n"); | ||
63 | for (i = 0; i < NUMTASKS; i++) { | ||
64 | printf(":: sending SIGKILL to %d\n", rt_task[i]); | ||
65 | kill(rt_task[i], SIGKILL); | ||
66 | } | ||
67 | for (i = 0; i < NUMTASKS; i++) { | ||
68 | pid = wait(&ret); | ||
69 | printf(":: %d exited with status %d\n", pid, ret); | ||
70 | } | ||
71 | printf(":: Leaving real-time mode.\n"); | ||
72 | set_rt_mode(MODE_NON_RT); | ||
73 | return 0; | ||
74 | } | ||
diff --git a/bin/rt_launch.c b/bin/rt_launch.c index d888365..186c0fa 100644 --- a/bin/rt_launch.c +++ b/bin/rt_launch.c | |||
@@ -6,7 +6,6 @@ | |||
6 | #include <signal.h> | 6 | #include <signal.h> |
7 | 7 | ||
8 | #include "litmus.h" | 8 | #include "litmus.h" |
9 | #include "adaptive.h" | ||
10 | 9 | ||
11 | typedef struct { | 10 | typedef struct { |
12 | char * exec_path; | 11 | char * exec_path; |
@@ -25,50 +24,20 @@ int launch(void *task_info_p) { | |||
25 | void usage(char *error) { | 24 | void usage(char *error) { |
26 | fprintf(stderr, "%s\nUsage: \nlaunch_rt supports one of two modes:\n" | 25 | fprintf(stderr, "%s\nUsage: \nlaunch_rt supports one of two modes:\n" |
27 | "\n\tlaunch_rt <SPORADIC OPTIONS> <wcet> <period> program arg1 arg2 ...\n" | 26 | "\n\tlaunch_rt <SPORADIC OPTIONS> <wcet> <period> program arg1 arg2 ...\n" |
28 | "\n\tlaunch_rt <ADAPTIVE OPTIONS> program arg1 arg2 ...\n" | ||
29 | "\nwhere:" | 27 | "\nwhere:" |
30 | "\n\t <SPORADIC OPTIONS> = " | 28 | "\n\t <SPORADIC OPTIONS> = " |
31 | "[-c {hrt|srt|be}] [-p <cpu>]\n" | 29 | "[-c {hrt|srt|be}] [-p <cpu>]\n" |
32 | "\n\t <ADAPTIVE OPTIONS> = " | ||
33 | "(-a weight/period/utility)+\n" | ||
34 | "\nExamples:" | 30 | "\nExamples:" |
35 | "\n\trt_launch -p 2 10 100 cpu_job" | 31 | "\n\trt_launch -p 2 10 100 cpu_job" |
36 | "\n\t => Launch cpu_job a hard real-time task with " | 32 | "\n\t => Launch cpu_job a hard real-time task with " |
37 | "\n\t period 100 and weight 0.1 on CPU 2.\n" | 33 | "\n\t period 100 and weight 0.1 on CPU 2.\n" |
38 | "\n\trt_launch -a 0.1/100/0.4 -a 0.2/75/0.5 adaptive_job" | ||
39 | "\n\t => Launch adaptive_job with two service levels" | ||
40 | "\n\n", | 34 | "\n\n", |
41 | error); | 35 | error); |
42 | exit(1); | 36 | exit(1); |
43 | } | 37 | } |
44 | 38 | ||
45 | /* argument format should be weight/period/utility */ | ||
46 | static int parse_service_level(service_level_t* level, char* str) | ||
47 | { | ||
48 | char *weight, *period, *utility; | ||
49 | double u, w; | ||
50 | weight = strtok(str, "/"); | ||
51 | period = strtok(NULL, "/"); | ||
52 | utility = strtok(NULL, "/"); | ||
53 | str = strtok(NULL, "/"); | ||
54 | |||
55 | if (str || !utility || !period || !weight) | ||
56 | return 0; | ||
57 | |||
58 | w = atof(weight); | ||
59 | u = atof(utility); | ||
60 | level->weight = f2fp(w); | ||
61 | level->period = atol(period); | ||
62 | level->value = f2fp(u); | ||
63 | |||
64 | if (level->period == 0 || | ||
65 | u <= 0.0 || u > 1.0 || w <= 0.0 || w > 1.0) | ||
66 | return 0; | ||
67 | return 1; | ||
68 | } | ||
69 | 39 | ||
70 | 40 | #define OPTSTR "p:c:" | |
71 | #define OPTSTR "p:c:a:" | ||
72 | 41 | ||
73 | int main(int argc, char** argv) | 42 | int main(int argc, char** argv) |
74 | { | 43 | { |
@@ -80,19 +49,8 @@ int main(int argc, char** argv) | |||
80 | startup_info_t info; | 49 | startup_info_t info; |
81 | task_class_t class = RT_CLASS_HARD; | 50 | task_class_t class = RT_CLASS_HARD; |
82 | 51 | ||
83 | int adaptive = 0; | ||
84 | unsigned int level = 0; | ||
85 | service_level_t slevel[MAX_SERVICE_LEVELS]; | ||
86 | |||
87 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | 52 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { |
88 | switch (opt) { | 53 | switch (opt) { |
89 | case 'a': | ||
90 | adaptive = 1; | ||
91 | if (level == MAX_SERVICE_LEVELS) | ||
92 | usage("Too many service levels."); | ||
93 | if (!parse_service_level(slevel + level++, optarg)) | ||
94 | usage("Bad service level."); | ||
95 | break; | ||
96 | case 'p': | 54 | case 'p': |
97 | cpu = atoi(optarg); | 55 | cpu = atoi(optarg); |
98 | break; | 56 | break; |
@@ -114,30 +72,22 @@ int main(int argc, char** argv) | |||
114 | 72 | ||
115 | signal(SIGUSR1, SIG_IGN); | 73 | signal(SIGUSR1, SIG_IGN); |
116 | 74 | ||
117 | if (!adaptive) { | 75 | if (argc - optind < 3) |
118 | if (argc - optind < 3) | 76 | usage("Arguments missing."); |
119 | usage("Arguments missing."); | 77 | wcet = atoi(argv[optind + 0]); |
120 | wcet = atoi(argv[optind + 0]); | 78 | period = atoi(argv[optind + 1]); |
121 | period = atoi(argv[optind + 1]); | 79 | if (wcet <= 0) |
122 | if (wcet <= 0) | 80 | usage("The worst-case execution time must be a " |
123 | usage("The worst-case execution time must be a " | 81 | "positive number."); |
124 | "positive number."); | 82 | if (period <= 0) |
125 | if (period <= 0) | 83 | usage("The period must be a positive number."); |
126 | usage("The period must be a positive number."); | 84 | if (wcet > period) { |
127 | if (wcet > period) { | 85 | usage("The worst-case execution time must not " |
128 | usage("The worst-case execution time must not " | 86 | "exceed the period."); |
129 | "exceed the period."); | ||
130 | } | ||
131 | info.exec_path = argv[optind + 2]; | ||
132 | info.argv = argv + optind + 2; | ||
133 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class); | ||
134 | } else { | ||
135 | if (argc == optind) | ||
136 | usage("Arguments missing."); | ||
137 | info.exec_path = argv[optind]; | ||
138 | info.argv = argv + optind; | ||
139 | ret = create_adaptive_rt_task(launch, &info, level, slevel); | ||
140 | } | 87 | } |
88 | info.exec_path = argv[optind + 2]; | ||
89 | info.argv = argv + optind + 2; | ||
90 | ret = __create_rt_task(launch, &info, cpu, wcet, period, class); | ||
141 | 91 | ||
142 | 92 | ||
143 | if (ret < 0) { | 93 | if (ret < 0) { |
diff --git a/bin/set_rt_mode.c b/bin/set_rt_mode.c deleted file mode 100644 index 510da70..0000000 --- a/bin/set_rt_mode.c +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <strings.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <string.h> | ||
5 | #include <errno.h> | ||
6 | |||
7 | #include "litmus.h" | ||
8 | |||
9 | |||
10 | void die(const char* str) | ||
11 | { | ||
12 | fprintf(stderr, "%s\n%s\n", str, | ||
13 | "Usage: set_rt_mode [-v] {on|off}"); | ||
14 | exit(127); | ||
15 | } | ||
16 | |||
17 | int main(int argc, char** argv) | ||
18 | { | ||
19 | int ret; | ||
20 | int verbose = 0; | ||
21 | char* cmd = argv[1]; | ||
22 | |||
23 | if (argc == 3 && !strcmp(argv[1], "-v")) { | ||
24 | verbose = 1; | ||
25 | cmd = argv[2]; | ||
26 | } | ||
27 | if (argc == 2 || verbose) { | ||
28 | if (!strcmp(cmd, "on")) { | ||
29 | if (verbose) | ||
30 | printf("Enabling real-time mode.\n"); | ||
31 | ret = set_rt_mode(MODE_RT_RUN); | ||
32 | if (ret && verbose) | ||
33 | perror("set_rt_mode failed"); | ||
34 | exit(ret ? errno : 0); | ||
35 | } else if (!strcmp(cmd, "off")) { | ||
36 | if (verbose) | ||
37 | printf("Disabling real-time mode.\n"); | ||
38 | ret = set_rt_mode(MODE_NON_RT); | ||
39 | if (ret && verbose) | ||
40 | perror("set_rt_mode failed"); | ||
41 | exit(ret ? errno : 0); | ||
42 | } | ||
43 | } | ||
44 | die("Bad arguments."); | ||
45 | return 0; | ||
46 | } | ||
diff --git a/bin/show_scheduler.c b/bin/show_scheduler.c deleted file mode 100644 index 7026e2a..0000000 --- a/bin/show_scheduler.c +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <stdio.h> | ||
3 | |||
4 | #include "litmus.h" | ||
5 | |||
6 | int main(int argc, char** argv) { | ||
7 | spolicy scheduler = sched_getpolicy(); | ||
8 | printf("%s\n", get_scheduler_name(scheduler)); | ||
9 | return 0; | ||
10 | } | ||
diff --git a/bin/stdump.c b/bin/stdump.c index 282fb31..30715dd 100644 --- a/bin/stdump.c +++ b/bin/stdump.c | |||
@@ -4,28 +4,8 @@ | |||
4 | 4 | ||
5 | 5 | ||
6 | #include "litmus.h" | 6 | #include "litmus.h" |
7 | #include "adaptive.h" | ||
8 | #include "sched_trace.h" | 7 | #include "sched_trace.h" |
9 | 8 | ||
10 | int show_sl_chg(trace_header_t* hdr) | ||
11 | { | ||
12 | service_level_change_record_t *rec; | ||
13 | |||
14 | rec = (service_level_change_record_t*) hdr; | ||
15 | printf("SL CHANGE : PID=%d PERIOD=%lu\n", rec->task.pid, | ||
16 | rec->new_level.period); | ||
17 | return 0; | ||
18 | } | ||
19 | |||
20 | int show_weight_error(trace_header_t* hdr) | ||
21 | { | ||
22 | weight_error_record_t *rec; | ||
23 | |||
24 | rec = (weight_error_record_t*) hdr; | ||
25 | printf("WEIGHT ERR: PID=%d EST=%5.4f ACT=%5.4f\n", rec->task, | ||
26 | fp2f(rec->estimate), fp2f(rec->actual)); | ||
27 | return 0; | ||
28 | } | ||
29 | 9 | ||
30 | 10 | ||
31 | int main(int argc, char** argv) | 11 | int main(int argc, char** argv) |
@@ -34,8 +14,6 @@ int main(int argc, char** argv) | |||
34 | int ret; | 14 | int ret; |
35 | 15 | ||
36 | init_record_callback(&cb); | 16 | init_record_callback(&cb); |
37 | set_callback(ST_SERVICE_LEVEL_CHANGE, show_sl_chg, &cb); | ||
38 | set_callback(ST_WEIGHT_ERROR, show_weight_error, &cb); | ||
39 | 17 | ||
40 | ret = walk_sched_trace_files_ordered(argv + 1, argc - 1, 0, &cb); | 18 | ret = walk_sched_trace_files_ordered(argv + 1, argc - 1, 0, &cb); |
41 | if (ret != 0) | 19 | if (ret != 0) |
diff --git a/bin/timeout.c b/bin/timeout.c deleted file mode 100644 index ba513f9..0000000 --- a/bin/timeout.c +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <unistd.h> | ||
4 | |||
5 | #include "litmus.h" | ||
6 | |||
7 | int main(int argc, char** argv) | ||
8 | { | ||
9 | int timeout; | ||
10 | rt_param_t my_param; | ||
11 | |||
12 | if (argc != 2) | ||
13 | { | ||
14 | printf("Usage: %s <timeout in seconds>\n", argv[0]); | ||
15 | exit(1); | ||
16 | } | ||
17 | timeout = atoi(argv[1]); | ||
18 | if (timeout <= 0) { | ||
19 | printf("Timeout must be a positive number.\n"); | ||
20 | exit(1); | ||
21 | } | ||
22 | |||
23 | /* printf("This is the kill real-time mode task.\n" | ||
24 | "Expected end of real %u seconds.\n", timeout); | ||
25 | */ | ||
26 | /* get_rt_task_param(getpid(), &my_param); | ||
27 | show_rt_param(&my_param); | ||
28 | */ | ||
29 | |||
30 | sleep(timeout); | ||
31 | |||
32 | |||
33 | set_rt_mode(MODE_NON_RT); | ||
34 | printf("End of real-time mode.\n"); | ||
35 | return 0; | ||
36 | } | ||
diff --git a/include/adaptive.h b/include/adaptive.h deleted file mode 100644 index 360b13e..0000000 --- a/include/adaptive.h +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #ifndef ADAPTIVE_H | ||
2 | #define ADAPTIVE_H | ||
3 | |||
4 | #define FP_SHIFT 10 | ||
5 | typedef struct | ||
6 | { | ||
7 | long val; | ||
8 | } fp_t; | ||
9 | |||
10 | static inline fp_t f2fp(double f) | ||
11 | { | ||
12 | return (fp_t) {f * (1 << FP_SHIFT)}; | ||
13 | } | ||
14 | |||
15 | static inline double fp2f(fp_t f) | ||
16 | { | ||
17 | return ((double) f.val) / (1 << FP_SHIFT); | ||
18 | } | ||
19 | |||
20 | |||
21 | #define MAX_SERVICE_LEVELS 10 | ||
22 | typedef struct { | ||
23 | fp_t weight; | ||
24 | unsigned long period; | ||
25 | fp_t value; | ||
26 | } service_level_t; | ||
27 | |||
28 | int set_service_levels(pid_t pid, | ||
29 | unsigned int nr_levels, | ||
30 | service_level_t* levels); | ||
31 | |||
32 | int get_cur_service_level(void); | ||
33 | |||
34 | int create_adaptive_rt_task(rt_fn_t rt_prog, void *arg, | ||
35 | unsigned int no_levels, service_level_t* levels); | ||
36 | |||
37 | |||
38 | #endif | ||
diff --git a/include/edf-hsb.h b/include/edf-hsb.h deleted file mode 100644 index 0ac3d4f..0000000 --- a/include/edf-hsb.h +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #ifndef EDF_HSB_H | ||
2 | #define EDF_HSB_H | ||
3 | |||
4 | |||
5 | int set_hrt(int cpu, unsigned int wcet, unsigned int period); | ||
6 | int get_hrt(int cpu, unsigned int *wcet, unsigned int *period); | ||
7 | int create_be(unsigned int wcet, unsigned int period); | ||
8 | |||
9 | |||
10 | #endif | ||
diff --git a/include/litmus.h b/include/litmus.h index c3cd51d..8918ae9 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -6,20 +6,6 @@ | |||
6 | /* A real-time program. */ | 6 | /* A real-time program. */ |
7 | typedef int (*rt_fn_t)(void*); | 7 | typedef int (*rt_fn_t)(void*); |
8 | 8 | ||
9 | /* Litmus scheduling policies */ | ||
10 | typedef enum { | ||
11 | SCHED_LINUX = 0, | ||
12 | SCHED_PFAIR = 1, | ||
13 | SCHED_PART_EDF = 3, | ||
14 | SCHED_GLOBAL_EDF = 5, | ||
15 | SCHED_PFAIR_DESYNC = 6, | ||
16 | SCHED_GLOBAL_EDF_NP = 7, | ||
17 | SCHED_EDF_HSB = 9, | ||
18 | SCHED_GSN_EDF = 10, | ||
19 | SCHED_PSN_EDF = 11, | ||
20 | SCHED_ADAPTIVE = 12, | ||
21 | } spolicy; | ||
22 | |||
23 | /* different types of clients */ | 9 | /* different types of clients */ |
24 | typedef enum { | 10 | typedef enum { |
25 | RT_CLASS_HARD, | 11 | RT_CLASS_HARD, |
@@ -48,12 +34,6 @@ typedef int pid_t; /* PID of a task */ | |||
48 | /* obtain the PID of a thread */ | 34 | /* obtain the PID of a thread */ |
49 | pid_t gettid(void); | 35 | pid_t gettid(void); |
50 | 36 | ||
51 | /* scheduler modes */ | ||
52 | #define MODE_NON_RT 0 | ||
53 | #define MODE_RT_RUN 1 | ||
54 | |||
55 | spolicy sched_getpolicy(void); | ||
56 | int set_rt_mode(int mode); | ||
57 | int set_rt_task_param(pid_t pid, rt_param_t* param); | 37 | int set_rt_task_param(pid_t pid, rt_param_t* param); |
58 | int get_rt_task_param(pid_t pid, rt_param_t* param); | 38 | int get_rt_task_param(pid_t pid, rt_param_t* param); |
59 | 39 | ||
@@ -66,18 +46,10 @@ int sporadic_task(unsigned long exec_cost, unsigned long period, | |||
66 | #define sporadic_partitioned(e, p, cpu) \ | 46 | #define sporadic_partitioned(e, p, cpu) \ |
67 | sporadic_task(e, p, cpu, RT_CLASS_SOFT) | 47 | sporadic_task(e, p, cpu, RT_CLASS_SOFT) |
68 | 48 | ||
69 | |||
70 | /* deprecated */ | ||
71 | enum { | ||
72 | LITMUS_RESERVED_RANGE = 1024, | ||
73 | } SCHED_SETUP_CMD; | ||
74 | int scheduler_setup(int cmd, void* param); | ||
75 | |||
76 | /* file descriptor attached shared objects support */ | 49 | /* file descriptor attached shared objects support */ |
77 | typedef enum { | 50 | typedef enum { |
78 | PI_SEM = 0, | 51 | PI_SEM = 0, |
79 | SRP_SEM = 1, | 52 | SRP_SEM = 1, |
80 | ICS_ID = 2, | ||
81 | } obj_type_t; | 53 | } obj_type_t; |
82 | 54 | ||
83 | int od_openx(int fd, obj_type_t type, int obj_id, void* config); | 55 | int od_openx(int fd, obj_type_t type, int obj_id, void* config); |
@@ -100,34 +72,6 @@ int get_job_no(unsigned int* job_no); | |||
100 | int wait_for_job_release(unsigned int job_no); | 72 | int wait_for_job_release(unsigned int job_no); |
101 | int sleep_next_period(void); | 73 | int sleep_next_period(void); |
102 | 74 | ||
103 | /* interruptible critical section support */ | ||
104 | #define MAX_ICS_NESTING 16 | ||
105 | #define ICS_STACK_EMPTY (-1) | ||
106 | |||
107 | struct ics_descriptor { | ||
108 | /* ICS id, only read by kernel */ | ||
109 | int id; | ||
110 | /* rollback program counter, only read by kernel */ | ||
111 | void* pc; | ||
112 | /* rollback stack pointer, not used by kernel */ | ||
113 | void* sp; | ||
114 | /* retry flag, not used by kernel */ | ||
115 | int* retry; | ||
116 | }; | ||
117 | |||
118 | /* ICS control block */ | ||
119 | struct ics_cb { | ||
120 | /* Points to the top-most valid entry. | ||
121 | * -1 indicates an empty stack. | ||
122 | * Read and written by kernel. | ||
123 | */ | ||
124 | int top; | ||
125 | struct ics_descriptor ics_stack[MAX_ICS_NESTING]; | ||
126 | }; | ||
127 | |||
128 | int reg_ics_cb(struct ics_cb* ics_cb); | ||
129 | int start_wcs(int od); | ||
130 | |||
131 | /* library functions */ | 75 | /* library functions */ |
132 | int init_litmus(void); | 76 | int init_litmus(void); |
133 | int init_rt_thread(void); | 77 | int init_rt_thread(void); |
@@ -144,7 +88,6 @@ enum rt_task_mode_t { | |||
144 | }; | 88 | }; |
145 | int task_mode(int target_mode); | 89 | int task_mode(int target_mode); |
146 | 90 | ||
147 | const char* get_scheduler_name(spolicy scheduler); | ||
148 | void show_rt_param(rt_param_t* tp); | 91 | void show_rt_param(rt_param_t* tp); |
149 | task_class_t str2class(const char* str); | 92 | task_class_t str2class(const char* str); |
150 | 93 | ||
diff --git a/include/sched_trace.h b/include/sched_trace.h index 1427107..5d2ddb3 100644 --- a/include/sched_trace.h +++ b/include/sched_trace.h | |||
@@ -17,9 +17,6 @@ typedef enum { | |||
17 | ST_JOB_COMPLETION = 6, | 17 | ST_JOB_COMPLETION = 6, |
18 | ST_CAPACITY_RELEASE = 7, | 18 | ST_CAPACITY_RELEASE = 7, |
19 | ST_CAPACITY_ALLOCATION = 8, | 19 | ST_CAPACITY_ALLOCATION = 8, |
20 | ST_SERVICE_LEVEL_CHANGE = 9, | ||
21 | ST_WEIGHT_ERROR = 10, | ||
22 | |||
23 | 20 | ||
24 | ST_MAX | 21 | ST_MAX |
25 | } trace_type_t; | 22 | } trace_type_t; |
@@ -96,24 +93,6 @@ typedef struct { | |||
96 | pid_t donor; | 93 | pid_t donor; |
97 | } cap_allocation_record_t; | 94 | } cap_allocation_record_t; |
98 | 95 | ||
99 | typedef struct { | ||
100 | trace_header_t header; | ||
101 | task_info_t task; | ||
102 | unsigned int from:16; | ||
103 | unsigned int to:16; | ||
104 | service_level_t new_level; | ||
105 | service_level_t old_level; | ||
106 | } service_level_change_record_t; | ||
107 | |||
108 | typedef struct { | ||
109 | trace_header_t header; | ||
110 | pid_t task; | ||
111 | fp_t estimate; | ||
112 | fp_t actual; | ||
113 | } weight_error_record_t; | ||
114 | |||
115 | |||
116 | |||
117 | 96 | ||
118 | 97 | ||
119 | 98 | ||
diff --git a/src/adaptive.c b/src/adaptive.c deleted file mode 100644 index 6a7d7a2..0000000 --- a/src/adaptive.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <unistd.h> | ||
3 | |||
4 | #include "litmus.h" | ||
5 | #include "internal.h" | ||
6 | #include "syscalls.h" | ||
7 | |||
8 | #include "adaptive.h" | ||
9 | |||
10 | #define __NR_set_service_levels 346 | ||
11 | #define __NR_get_cur_service_level 347 | ||
12 | |||
13 | |||
14 | |||
15 | int set_service_levels(pid_t pid, | ||
16 | unsigned int nr_levels, | ||
17 | service_level_t* levels) | ||
18 | { | ||
19 | return syscall(__NR_set_service_levels, pid, nr_levels, levels); | ||
20 | } | ||
21 | |||
22 | |||
23 | int get_cur_service_level(void) | ||
24 | { | ||
25 | return syscall(__NR_get_cur_service_level); | ||
26 | } | ||
27 | |||
28 | |||
29 | struct adaptive_param { | ||
30 | unsigned int no_levels; | ||
31 | service_level_t* levels; | ||
32 | }; | ||
33 | |||
34 | int setup_adaptive(int pid, struct adaptive_param* arg) | ||
35 | { | ||
36 | return set_service_levels(pid, arg->no_levels, arg->levels); | ||
37 | } | ||
38 | |||
39 | int create_adaptive_rt_task(rt_fn_t rt_prog, void *arg, | ||
40 | unsigned int no_levels, service_level_t* levels) | ||
41 | { | ||
42 | struct adaptive_param p; | ||
43 | p.no_levels = no_levels; | ||
44 | p.levels = levels; | ||
45 | return __launch_rt_task(rt_prog, arg, | ||
46 | (rt_setup_fn_t) setup_adaptive, &p); | ||
47 | } | ||
48 | |||
diff --git a/src/edf-hsb.c b/src/edf-hsb.c deleted file mode 100644 index 9ace2ca..0000000 --- a/src/edf-hsb.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | #include "litmus.h" | ||
2 | #include "edf-hsb.h" | ||
3 | |||
4 | |||
5 | typedef enum { | ||
6 | EDF_HSB_SET_HRT, | ||
7 | EDF_HSB_GET_HRT, | ||
8 | EDF_HSB_CREATE_BE | ||
9 | } edf_hsb_setup_cmds_t; | ||
10 | |||
11 | typedef struct { | ||
12 | int cpu; | ||
13 | unsigned int wcet; | ||
14 | unsigned int period; | ||
15 | } setup_hrt_param_t; | ||
16 | |||
17 | typedef struct { | ||
18 | unsigned int wcet; | ||
19 | unsigned int period; | ||
20 | } create_be_param_t; | ||
21 | |||
22 | int set_hrt(int cpu, unsigned int wcet, unsigned int period) | ||
23 | { | ||
24 | setup_hrt_param_t param; | ||
25 | param.cpu = cpu; | ||
26 | param.wcet = wcet; | ||
27 | param.period = period; | ||
28 | return scheduler_setup(EDF_HSB_SET_HRT, ¶m); | ||
29 | } | ||
30 | |||
31 | int get_hrt(int cpu, unsigned int *wcet, unsigned int *period) | ||
32 | { | ||
33 | setup_hrt_param_t param; | ||
34 | int ret; | ||
35 | param.cpu = cpu; | ||
36 | ret = scheduler_setup(EDF_HSB_GET_HRT, ¶m); | ||
37 | *wcet = param.wcet; | ||
38 | *period = param.period; | ||
39 | return ret; | ||
40 | } | ||
41 | |||
42 | int create_be(unsigned int wcet, unsigned int period) | ||
43 | { | ||
44 | create_be_param_t param; | ||
45 | param.wcet = wcet; | ||
46 | param.period = period; | ||
47 | return scheduler_setup(EDF_HSB_CREATE_BE, ¶m); | ||
48 | } | ||
diff --git a/src/litmus.c b/src/litmus.c index cc23263..8f5dfe8 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -8,43 +8,6 @@ | |||
8 | #include "litmus.h" | 8 | #include "litmus.h" |
9 | #include "internal.h" | 9 | #include "internal.h" |
10 | 10 | ||
11 | const char* get_scheduler_name(spolicy scheduler) | ||
12 | { | ||
13 | const char* name; | ||
14 | |||
15 | switch (scheduler){ | ||
16 | case SCHED_LINUX : | ||
17 | name = "Linux"; | ||
18 | break; | ||
19 | case SCHED_PFAIR: | ||
20 | name = "Pfair"; | ||
21 | break; | ||
22 | case SCHED_PART_EDF: | ||
23 | name = "Partioned EDF"; | ||
24 | break; | ||
25 | case SCHED_GLOBAL_EDF: | ||
26 | name = "Global EDF"; | ||
27 | break; | ||
28 | case SCHED_EDF_HSB: | ||
29 | name = "EDF-HSB"; | ||
30 | break; | ||
31 | case SCHED_GSN_EDF: | ||
32 | name = "GSN-EDF"; | ||
33 | break; | ||
34 | case SCHED_PSN_EDF: | ||
35 | name = "PSN-EDF"; | ||
36 | break; | ||
37 | case SCHED_ADAPTIVE: | ||
38 | name = "ADAPTIVE"; | ||
39 | break; | ||
40 | default: | ||
41 | name = "Unkown"; | ||
42 | break; | ||
43 | } | ||
44 | return name; | ||
45 | } | ||
46 | |||
47 | |||
48 | void show_rt_param(rt_param_t* tp) | 11 | void show_rt_param(rt_param_t* tp) |
49 | { | 12 | { |
50 | printf("rt params:\n\t" | 13 | printf("rt params:\n\t" |
diff --git a/src/sched_trace.c b/src/sched_trace.c index 18969bd..c3a603b 100644 --- a/src/sched_trace.c +++ b/src/sched_trace.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | #include "litmus.h" | 10 | #include "litmus.h" |
11 | #include "adaptive.h" | ||
12 | #include "sched_trace.h" | 11 | #include "sched_trace.h" |
13 | 12 | ||
14 | 13 | ||
diff --git a/src/syscalls.c b/src/syscalls.c index 3b2f76c..0924818 100644 --- a/src/syscalls.c +++ b/src/syscalls.c | |||
@@ -41,12 +41,9 @@ struct np_flag; | |||
41 | 41 | ||
42 | _syscall0(pid_t, gettid); | 42 | _syscall0(pid_t, gettid); |
43 | 43 | ||
44 | _syscall0(spolicy, sched_getpolicy); | ||
45 | _syscall1(int, set_rt_mode, int, arg1); | ||
46 | _syscall2(int, set_rt_task_param, pid_t, pid, rt_param_t*, arg1); | 44 | _syscall2(int, set_rt_task_param, pid_t, pid, rt_param_t*, arg1); |
47 | _syscall2(int, get_rt_task_param, pid_t, pid, rt_param_t*, arg1); | 45 | _syscall2(int, get_rt_task_param, pid_t, pid, rt_param_t*, arg1); |
48 | _syscall0(int, sleep_next_period); | 46 | _syscall0(int, sleep_next_period); |
49 | _syscall2(int, scheduler_setup, int, cmd, void*, param); | ||
50 | _syscall1(int, register_np_flag, struct np_flag*, flag); | 47 | _syscall1(int, register_np_flag, struct np_flag*, flag); |
51 | _syscall0(int, signal_exit_np); | 48 | _syscall0(int, signal_exit_np); |
52 | 49 | ||
@@ -58,10 +55,6 @@ _syscall1(int, pi_up, int, od); | |||
58 | _syscall1(int, srp_down, int, od); | 55 | _syscall1(int, srp_down, int, od); |
59 | _syscall1(int, srp_up, int, od); | 56 | _syscall1(int, srp_up, int, od); |
60 | _syscall1(int, reg_task_srp_sem, int, od); | 57 | _syscall1(int, reg_task_srp_sem, int, od); |
61 | |||
62 | _syscall1(int, get_job_no, unsigned int*, job_no); | 58 | _syscall1(int, get_job_no, unsigned int*, job_no); |
63 | _syscall1(int, wait_for_job_release, unsigned int, job_no); | 59 | _syscall1(int, wait_for_job_release, unsigned int, job_no); |
64 | |||
65 | _syscall1(int, start_wcs, int, od); | ||
66 | _syscall1(int, reg_ics_cb, struct ics_cb*, ics_cb); | ||
67 | _syscall1(int, task_mode, int, target_mode); | 60 | _syscall1(int, task_mode, int, target_mode); |