diff options
Diffstat (limited to 'bin/rt_launch.c')
-rw-r--r-- | bin/rt_launch.c | 82 |
1 files changed, 16 insertions, 66 deletions
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) { |