diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-06-24 21:08:02 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-01-26 18:20:24 -0500 |
commit | dbf6cfe8cb089bd6921b3b9811e175fd496c9d0f (patch) | |
tree | cee70cc296979afc6e516a34eb9ad95a9c74feed | |
parent | ee0741ad269e55f2334d4044c3f66f7897130890 (diff) |
[NPS-F] Add rt_launch version for NPS-F algo
-rw-r--r-- | SConstruct | 3 | ||||
-rw-r--r-- | bin/rt_launch_npsf.c | 110 | ||||
-rw-r--r-- | include/litmus.h | 2 | ||||
-rw-r--r-- | src/task.c | 17 |
4 files changed, 131 insertions, 1 deletions
@@ -209,9 +209,10 @@ mtrt.Program('base_mt_task', 'bin/base_mt_task.c') | |||
209 | rt.Program('rt_launch', ['bin/rt_launch.c', 'bin/common.c']) | 209 | rt.Program('rt_launch', ['bin/rt_launch.c', 'bin/common.c']) |
210 | rt.Program('rtspin', ['bin/rtspin.c', 'bin/common.c']) | 210 | rt.Program('rtspin', ['bin/rtspin.c', 'bin/common.c']) |
211 | rt.Program('rtspin_edffm', ['bin/rtspin_edffm.c', 'bin/common.c']) | 211 | rt.Program('rtspin_edffm', ['bin/rtspin_edffm.c', 'bin/common.c']) |
212 | rt.Program('rt_launch_edffm', ['bin/rt_launch_edffm.c', 'bin/common.c']) | ||
212 | rt.Program('rtspin_npsf', ['bin/rtspin_npsf.c', 'bin/common.c']) | 213 | rt.Program('rtspin_npsf', ['bin/rtspin_npsf.c', 'bin/common.c']) |
213 | rt.Program('npsf_add_server', ['bin/npsf_add_server.c', 'bin/common.c']) | 214 | rt.Program('npsf_add_server', ['bin/npsf_add_server.c', 'bin/common.c']) |
214 | rt.Program('rt_launch_edffm', ['bin/rt_launch_edffm.c', 'bin/common.c']) | 215 | rt.Program('rt_launch_npsf', ['bin/rt_launch_npsf.c', 'bin/common.c']) |
215 | rt.Program('release_ts', 'bin/release_ts.c') | 216 | rt.Program('release_ts', 'bin/release_ts.c') |
216 | rtm.Program('measure_syscall', 'bin/null_call.c') | 217 | rtm.Program('measure_syscall', 'bin/null_call.c') |
217 | 218 | ||
diff --git a/bin/rt_launch_npsf.c b/bin/rt_launch_npsf.c new file mode 100644 index 0000000..97ad361 --- /dev/null +++ b/bin/rt_launch_npsf.c | |||
@@ -0,0 +1,110 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | #include <unistd.h> | ||
5 | #include <limits.h> | ||
6 | #include <signal.h> | ||
7 | |||
8 | #include "litmus.h" | ||
9 | #include "common.h" | ||
10 | |||
11 | typedef struct { | ||
12 | int wait; | ||
13 | char * exec_path; | ||
14 | char ** argv; | ||
15 | } startup_info_t; | ||
16 | |||
17 | |||
18 | int launch(void *task_info_p) { | ||
19 | startup_info_t *info = (startup_info_t*) task_info_p; | ||
20 | int ret; | ||
21 | if (info->wait) { | ||
22 | ret = wait_for_ts_release(); | ||
23 | if (ret != 0) | ||
24 | perror("wait_for_ts_release()"); | ||
25 | } | ||
26 | ret = execvp(info->exec_path, info->argv); | ||
27 | perror("execv failed"); | ||
28 | return ret; | ||
29 | } | ||
30 | |||
31 | void usage(char *error) { | ||
32 | fprintf(stderr, "%s\nUsage: rt_launch [-w][-v] wcet period cpu npsf-id program [arg1 arg2 ...]\n" | ||
33 | "\t-w\tSynchronous release\n" | ||
34 | "\t-v\tVerbose\n" | ||
35 | "\twcet, period in ms\n" | ||
36 | "\tprogram to be launched\n", | ||
37 | error); | ||
38 | exit(1); | ||
39 | } | ||
40 | |||
41 | |||
42 | #define OPTSTR "vw" | ||
43 | |||
44 | int main(int argc, char** argv) | ||
45 | { | ||
46 | int ret; | ||
47 | lt_t wcet; | ||
48 | lt_t period; | ||
49 | int migrate = 0; | ||
50 | int cpu = 0; | ||
51 | int npsf_id; | ||
52 | int opt; | ||
53 | int verbose = 0; | ||
54 | int wait = 0; | ||
55 | startup_info_t info; | ||
56 | |||
57 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | ||
58 | switch (opt) { | ||
59 | case 'w': | ||
60 | wait = 1; | ||
61 | break; | ||
62 | case 'v': | ||
63 | verbose = 1; | ||
64 | break; | ||
65 | case ':': | ||
66 | usage("Argument missing."); | ||
67 | break; | ||
68 | case '?': | ||
69 | default: | ||
70 | usage("Bad argument."); | ||
71 | break; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | signal(SIGUSR1, SIG_IGN); | ||
76 | |||
77 | if (argc - optind < 5) | ||
78 | usage("Arguments missing."); | ||
79 | wcet = ms2lt(atoi(argv[optind + 0])); | ||
80 | period = ms2lt(atoi(argv[optind + 1])); | ||
81 | cpu = atoi(argv[optind + 2]); | ||
82 | migrate = 1; | ||
83 | npsf_id = atoi(argv[optind + 3]); | ||
84 | if (wcet <= 0) | ||
85 | usage("The worst-case execution time must be a " | ||
86 | "positive number."); | ||
87 | if (period <= 0) | ||
88 | usage("The period must be a positive number."); | ||
89 | if (wcet > period) { | ||
90 | usage("The worst-case execution time must not " | ||
91 | "exceed the period."); | ||
92 | } | ||
93 | info.exec_path = argv[optind + 4]; | ||
94 | info.argv = argv + optind + 4; | ||
95 | info.wait = wait; | ||
96 | if (migrate) { | ||
97 | ret = be_migrate_to(cpu); | ||
98 | if (ret < 0) | ||
99 | bail_out("could not migrate to target partition"); | ||
100 | } | ||
101 | ret = __create_rt_task_npsf(launch, &info, cpu, wcet, period, npsf_id, RT_CLASS_HARD); | ||
102 | |||
103 | |||
104 | if (ret < 0) | ||
105 | bail_out("could not create rt child process"); | ||
106 | else if (verbose) | ||
107 | printf("%d\n", ret); | ||
108 | |||
109 | return 0; | ||
110 | } | ||
diff --git a/include/litmus.h b/include/litmus.h index d7f7b99..9d2339f 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -98,6 +98,8 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | |||
98 | int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | 98 | int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
99 | int period, lt_t *frac1, lt_t *frac2, | 99 | int period, lt_t *frac1, lt_t *frac2, |
100 | int cpu1, int cpu2, task_class_t class); | 100 | int cpu1, int cpu2, task_class_t class); |
101 | int __create_rt_task_npsf(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | ||
102 | int period, task_class_t class, int npsf_id); | ||
101 | 103 | ||
102 | /* per-task modes */ | 104 | /* per-task modes */ |
103 | enum rt_task_mode_t { | 105 | enum rt_task_mode_t { |
@@ -69,6 +69,23 @@ int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | |||
69 | (rt_setup_fn_t) set_rt_task_param, ¶ms); | 69 | (rt_setup_fn_t) set_rt_task_param, ¶ms); |
70 | } | 70 | } |
71 | 71 | ||
72 | int __create_rt_task_npsf(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | ||
73 | int period, task_class_t class, int npsf_id) | ||
74 | { | ||
75 | struct rt_task params; | ||
76 | params.cpu = cpu; | ||
77 | params.period = period; | ||
78 | params.exec_cost = wcet; | ||
79 | params.cls = class; | ||
80 | params.phase = 0; | ||
81 | /* enforce budget for tasks that might not use sleep_next_period() */ | ||
82 | params.budget_policy = QUANTUM_ENFORCEMENT; | ||
83 | params.npsf_id = npsf_id; | ||
84 | |||
85 | return __launch_rt_task(rt_prog, arg, | ||
86 | (rt_setup_fn_t) set_rt_task_param, ¶ms); | ||
87 | } | ||
88 | |||
72 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, | 89 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, |
73 | task_class_t class) | 90 | task_class_t class) |
74 | { | 91 | { |