aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Erickson <jerickso@cs.unc.edu>2012-05-26 17:55:16 -0400
committerJeremy Erickson <jerickso@cs.unc.edu>2012-05-26 17:55:16 -0400
commitda7a2586be45bc784480c440fd8d627a796df671 (patch)
tree3687eb98156ab2368469d1d3729a9f0f97c8cc27
parent8000ef44f4a82d845d5139cebfcac047ee291433 (diff)
Split factor support
-rw-r--r--bin/rt_launch.c21
-rw-r--r--bin/rtspin.c28
-rw-r--r--include/litmus.h13
-rw-r--r--src/litmus.c7
-rw-r--r--src/task.c11
5 files changed, 48 insertions, 32 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c
index 3863031..2d195bd 100644
--- a/bin/rt_launch.c
+++ b/bin/rt_launch.c
@@ -29,9 +29,10 @@ int launch(void *task_info_p) {
29} 29}
30 30
31void usage(char *error) { 31void usage(char *error) {
32 fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-p cpu][-c hrt | srt | be] wcet period program [arg1 arg2 ...]\n" 32 fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-n split][-p cpu][-c hrt | srt | be] wcet period program [arg1 arg2 ...]\n"
33 "\t-w\tSynchronous release\n" 33 "\t-w\tSynchronous release\n"
34 "\t-v\tVerbose\n" 34 "\t-v\tVerbose\n"
35 "\t-n\tSplit factor\n"
35 "\t-p\tcpu (or initial cpu)\n" 36 "\t-p\tcpu (or initial cpu)\n"
36 "\t-c\tClass\n" 37 "\t-c\tClass\n"
37 "\twcet, period in ms\n" 38 "\twcet, period in ms\n"
@@ -41,7 +42,7 @@ void usage(char *error) {
41} 42}
42 43
43 44
44#define OPTSTR "p:c:vw" 45#define OPTSTR "p:c:vwn:"
45 46
46int main(int argc, char** argv) 47int main(int argc, char** argv)
47{ 48{
@@ -49,6 +50,7 @@ int main(int argc, char** argv)
49 lt_t wcet; 50 lt_t wcet;
50 lt_t period; 51 lt_t period;
51 int migrate = 0; 52 int migrate = 0;
53 int split = 1;
52 int cpu = 0; 54 int cpu = 0;
53 int opt; 55 int opt;
54 int verbose = 0; 56 int verbose = 0;
@@ -64,6 +66,9 @@ int main(int argc, char** argv)
64 case 'v': 66 case 'v':
65 verbose = 1; 67 verbose = 1;
66 break; 68 break;
69 case 'n':
70 split = atoi(optarg);
71 break;
67 case 'p': 72 case 'p':
68 cpu = atoi(optarg); 73 cpu = atoi(optarg);
69 migrate = 1; 74 migrate = 1;
@@ -87,27 +92,27 @@ int main(int argc, char** argv)
87 signal(SIGUSR1, SIG_IGN); 92 signal(SIGUSR1, SIG_IGN);
88 93
89 if (argc - optind < 3) 94 if (argc - optind < 3)
90 usage("Arguments missing."); 95 usage("Arguments missing.");
91 wcet = ms2lt(atoi(argv[optind + 0])); 96 wcet = ms2lt(atoi(argv[optind + 0]));
92 period = ms2lt(atoi(argv[optind + 1])); 97 period = ms2lt(atoi(argv[optind + 1]));
93 if (wcet <= 0) 98 if (wcet <= 0)
94 usage("The worst-case execution time must be a " 99 usage("The worst-case execution time must be a "
95 "positive number."); 100 "positive number.");
96 if (period <= 0) 101 if (period <= 0)
97 usage("The period must be a positive number."); 102 usage("The period must be a positive number.");
98 if (wcet > period) { 103 if (wcet > period) {
99 usage("The worst-case execution time must not " 104 usage("The worst-case execution time must not "
100 "exceed the period."); 105 "exceed the period.");
101 } 106 }
102 info.exec_path = argv[optind + 2]; 107 info.exec_path = argv[optind + 2];
103 info.argv = argv + optind + 2; 108 info.argv = argv + optind + 2;
104 info.wait = wait; 109 info.wait = wait;
105 if (migrate) { 110 if (migrate) {
106 ret = be_migrate_to(cpu); 111 ret = be_migrate_to(cpu);
107 if (ret < 0) 112 if (ret < 0)
108 bail_out("could not migrate to target partition"); 113 bail_out("could not migrate to target partition");
109 } 114 }
110 ret = __create_rt_task(launch, &info, cpu, wcet, period, class); 115 ret = __create_rt_task(launch, &info, split, cpu, wcet, period, class);
111 116
112 117
113 if (ret < 0) 118 if (ret < 0)
diff --git a/bin/rtspin.c b/bin/rtspin.c
index ae76941..1d60524 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -20,7 +20,7 @@ static void usage(char *error) {
20 " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n" 20 " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n"
21 " rt_spin -l\n" 21 " rt_spin -l\n"
22 "\n" 22 "\n"
23 "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE]\n" 23 "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE] [-n SPLIT]\n"
24 "\n" 24 "\n"
25 "WCET and PERIOD are milliseconds, DURATION is seconds.\n"); 25 "WCET and PERIOD are milliseconds, DURATION is seconds.\n");
26 exit(EXIT_FAILURE); 26 exit(EXIT_FAILURE);
@@ -45,7 +45,7 @@ static void skip_comments(FILE *fstream)
45} 45}
46 46
47static void get_exec_times(const char *file, const int column, 47static void get_exec_times(const char *file, const int column,
48 int *num_jobs, double **exec_times) 48 int *num_jobs, double **exec_times)
49{ 49{
50 FILE *fstream; 50 FILE *fstream;
51 int cur_job, cur_col, ch; 51 int cur_job, cur_col, ch;
@@ -142,10 +142,10 @@ static void debug_delay_loop(void)
142 loop_for(delay, 0); 142 loop_for(delay, 0);
143 end = wctime(); 143 end = wctime();
144 printf("%6.4fs: looped for %10.8fs, delta=%11.8fs, error=%7.4f%%\n", 144 printf("%6.4fs: looped for %10.8fs, delta=%11.8fs, error=%7.4f%%\n",
145 delay, 145 delay,
146 end - start, 146 end - start,
147 end - start - delay, 147 end - start - delay,
148 100 * (end - start - delay) / delay); 148 100 * (end - start - delay) / delay);
149 } 149 }
150 } 150 }
151} 151}
@@ -161,7 +161,7 @@ static int job(double exec_time, double program_end)
161 } 161 }
162} 162}
163 163
164#define OPTSTR "p:c:wlveo:f:s:" 164#define OPTSTR "p:c:wlveo:f:s:n:"
165 165
166int main(int argc, char** argv) 166int main(int argc, char** argv)
167{ 167{
@@ -170,6 +170,7 @@ int main(int argc, char** argv)
170 lt_t period; 170 lt_t period;
171 double wcet_ms, period_ms; 171 double wcet_ms, period_ms;
172 int migrate = 0; 172 int migrate = 0;
173 int split = 1;
173 int cpu = 0; 174 int cpu = 0;
174 int opt; 175 int opt;
175 int wait = 0; 176 int wait = 0;
@@ -190,6 +191,9 @@ int main(int argc, char** argv)
190 case 'w': 191 case 'w':
191 wait = 1; 192 wait = 1;
192 break; 193 break;
194 case 'n':
195 split = atoi(optarg);
196 break;
193 case 'p': 197 case 'p':
194 cpu = atoi(optarg); 198 cpu = atoi(optarg);
195 migrate = 1; 199 migrate = 1;
@@ -258,6 +262,8 @@ int main(int argc, char** argv)
258 "positive number."); 262 "positive number.");
259 if (period <= 0) 263 if (period <= 0)
260 usage("The period must be a positive number."); 264 usage("The period must be a positive number.");
265 if (split <= 0)
266 usage("The split factor must be a positive number, if specified.");
261 if (!file && wcet > period) { 267 if (!file && wcet > period) {
262 usage("The worst-case execution time must not " 268 usage("The worst-case execution time must not "
263 "exceed the period."); 269 "exceed the period.");
@@ -274,10 +280,10 @@ int main(int argc, char** argv)
274 bail_out("could not migrate to target partition"); 280 bail_out("could not migrate to target partition");
275 } 281 }
276 282
277 ret = sporadic_task_ns(wcet, period, 0, cpu, class, 283 ret = sporadic_task_ns(wcet, period, 0, split, cpu, class,
278 want_enforcement ? PRECISE_ENFORCEMENT 284 want_enforcement ? PRECISE_ENFORCEMENT
279 : NO_ENFORCEMENT, 285 : NO_ENFORCEMENT,
280 migrate); 286 migrate);
281 if (ret < 0) 287 if (ret < 0)
282 bail_out("could not setup rt task params"); 288 bail_out("could not setup rt task params");
283 289
diff --git a/include/litmus.h b/include/litmus.h
index 4c85d28..78fb4f4 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -31,21 +31,21 @@ int get_rt_task_param(pid_t pid, struct rt_task* param);
31 31
32/* times are given in ms */ 32/* times are given in ms */
33int sporadic_task( 33int sporadic_task(
34 lt_t e, lt_t p, lt_t phase, 34 lt_t e, lt_t p, lt_t phase, int split,
35 int partition, task_class_t cls, 35 int partition, task_class_t cls,
36 budget_policy_t budget_policy, int set_cpu_set); 36 budget_policy_t budget_policy, int set_cpu_set);
37 37
38/* times are given in ns */ 38/* times are given in ns */
39int sporadic_task_ns( 39int sporadic_task_ns(
40 lt_t e, lt_t p, lt_t phase, 40 lt_t e, lt_t p, lt_t phase, int split,
41 int cpu, task_class_t cls, 41 int cpu, task_class_t cls,
42 budget_policy_t budget_policy, int set_cpu_set); 42 budget_policy_t budget_policy, int set_cpu_set);
43 43
44/* budget enforcement off by default in these macros */ 44/* budget enforcement off by default in these macros */
45#define sporadic_global(e, p) \ 45#define sporadic_global(e, p) \
46 sporadic_task(e, p, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) 46 sporadic_task(e, p, 0, 1, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0)
47#define sporadic_partitioned(e, p, cpu) \ 47#define sporadic_partitioned(e, p, cpu) \
48 sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) 48 sporadic_task(e, p, 0, 1, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1)
49 49
50/* file descriptor attached shared objects support */ 50/* file descriptor attached shared objects support */
51typedef enum { 51typedef enum {
@@ -79,8 +79,9 @@ void exit_litmus(void);
79typedef int (*rt_fn_t)(void*); 79typedef int (*rt_fn_t)(void*);
80 80
81/* These two functions configure the RT task to use enforced exe budgets */ 81/* These two functions configure the RT task to use enforced exe budgets */
82int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period); 82int create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet,
83int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, 83 int period);
84int __create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet,
84 int period, task_class_t cls); 85 int period, task_class_t cls);
85 86
86/* per-task modes */ 87/* per-task modes */
diff --git a/src/litmus.c b/src/litmus.c
index d3cc6bb..bb08e87 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -41,15 +41,15 @@ int be_migrate_to(int target_cpu)
41 return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); 41 return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set);
42} 42}
43 43
44int sporadic_task(lt_t e, lt_t p, lt_t phase, 44int sporadic_task(lt_t e, lt_t p, lt_t phase, int split,
45 int cpu, task_class_t cls, 45 int cpu, task_class_t cls,
46 budget_policy_t budget_policy, int set_cpu_set) 46 budget_policy_t budget_policy, int set_cpu_set)
47{ 47{
48 return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, 48 return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS,
49 cpu, cls, budget_policy, set_cpu_set); 49 split, cpu, cls, budget_policy, set_cpu_set);
50} 50}
51 51
52int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, 52int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, int split,
53 int cpu, task_class_t cls, 53 int cpu, task_class_t cls,
54 budget_policy_t budget_policy, int set_cpu_set) 54 budget_policy_t budget_policy, int set_cpu_set)
55{ 55{
@@ -63,6 +63,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase,
63 63
64 param.exec_cost = e; 64 param.exec_cost = e;
65 param.period = p; 65 param.period = p;
66 param.split = split;
66 param.cpu = cpu; 67 param.cpu = cpu;
67 param.cls = cls; 68 param.cls = cls;
68 param.phase = phase; 69 param.phase = phase;
diff --git a/src/task.c b/src/task.c
index 4d237bd..1d374f4 100644
--- a/src/task.c
+++ b/src/task.c
@@ -40,10 +40,11 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup,
40 return rt_task; 40 return rt_task;
41} 41}
42 42
43int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, 43int __create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet,
44 task_class_t class) 44 int period, task_class_t class)
45{ 45{
46 struct rt_task params; 46 struct rt_task params;
47 params.split = split;
47 params.cpu = cpu; 48 params.cpu = cpu;
48 params.period = period; 49 params.period = period;
49 params.exec_cost = wcet; 50 params.exec_cost = wcet;
@@ -56,8 +57,10 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period,
56 (rt_setup_fn_t) set_rt_task_param, &params); 57 (rt_setup_fn_t) set_rt_task_param, &params);
57} 58}
58 59
59int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period) { 60int create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet,
60 return __create_rt_task(rt_prog, arg, cpu, wcet, period, RT_CLASS_HARD); 61 int period) {
62 return __create_rt_task(rt_prog, arg, split, cpu, wcet, period,
63 RT_CLASS_HARD);
61} 64}
62 65
63 66