diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-06-15 16:35:17 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-01-26 18:20:23 -0500 |
commit | f8428ba547bd70398f2fe0379a4fc5e2c2983066 (patch) | |
tree | 212910d8954e44401b48fa4cd26ac6683d4c354a /bin | |
parent | 0a06230478a52a18d433735305c2cb6fc6de68da (diff) |
[EDF-fm] Add rt_launch_edffm and support for edffm task creation
Diffstat (limited to 'bin')
-rw-r--r-- | bin/rt_launch_edffm.c | 133 | ||||
-rw-r--r-- | bin/rtspin_edffm.c | 2 |
2 files changed, 134 insertions, 1 deletions
diff --git a/bin/rt_launch_edffm.c b/bin/rt_launch_edffm.c new file mode 100644 index 0000000..fcb895e --- /dev/null +++ b/bin/rt_launch_edffm.c | |||
@@ -0,0 +1,133 @@ | |||
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][-p cpu][-c hrt | srt | be] wcet period" | ||
33 | " fracnum1 fracden2 fracnum2 fracden2 cpu1 cpu2 program [arg1 arg2 ...]\n" | ||
34 | "\t-w\tSynchronous release\n" | ||
35 | "\t-v\tVerbose\n" | ||
36 | "\t-p\tcpu (or initial cpu)\n" | ||
37 | "\t-c\tClass\n" | ||
38 | "\twcet, period in ms\n" | ||
39 | "\tprogram to be launched\n", | ||
40 | error); | ||
41 | exit(1); | ||
42 | } | ||
43 | |||
44 | |||
45 | #define OPTSTR "p:c:vw" | ||
46 | |||
47 | int main(int argc, char** argv) | ||
48 | { | ||
49 | int ret; | ||
50 | lt_t wcet; | ||
51 | lt_t period; | ||
52 | /* [num,den] */ | ||
53 | lt_t frac1[2], frac2[2]; | ||
54 | int cpu1, cpu2; | ||
55 | int migrate = 0; | ||
56 | int cpu = 0; | ||
57 | int opt; | ||
58 | int verbose = 0; | ||
59 | int wait = 0; | ||
60 | startup_info_t info; | ||
61 | task_class_t class = RT_CLASS_HARD; | ||
62 | |||
63 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | ||
64 | switch (opt) { | ||
65 | case 'w': | ||
66 | wait = 1; | ||
67 | break; | ||
68 | case 'v': | ||
69 | verbose = 1; | ||
70 | break; | ||
71 | case 'p': | ||
72 | cpu = atoi(optarg); | ||
73 | migrate = 1; | ||
74 | break; | ||
75 | case 'c': | ||
76 | class = str2class(optarg); | ||
77 | if (class == -1) | ||
78 | usage("Unknown task class."); | ||
79 | break; | ||
80 | |||
81 | case ':': | ||
82 | usage("Argument missing."); | ||
83 | break; | ||
84 | case '?': | ||
85 | default: | ||
86 | usage("Bad argument."); | ||
87 | break; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | signal(SIGUSR1, SIG_IGN); | ||
92 | |||
93 | if (argc - optind < 8) | ||
94 | usage("Arguments missing."); | ||
95 | wcet = ms2lt(atoi(argv[optind + 0])); | ||
96 | period = ms2lt(atoi(argv[optind + 1])); | ||
97 | /* frac num, den = 0 means fixed task */ | ||
98 | frac1[0] = atoi(argv[optind + 2]); | ||
99 | frac1[1] = atoi(argv[optind + 3]); | ||
100 | frac2[0] = atoi(argv[optind + 4]); | ||
101 | frac2[1] = atoi(argv[optind + 5]); | ||
102 | cpu1 = atoi(argv[optind + 6]); | ||
103 | cpu2 = atoi(argv[optind + 7]); | ||
104 | if (wcet <= 0) | ||
105 | usage("The worst-case execution time must be a " | ||
106 | "positive number."); | ||
107 | if (period <= 0) | ||
108 | usage("The period must be a positive number."); | ||
109 | if (wcet > period) { | ||
110 | usage("The worst-case execution time must not " | ||
111 | "exceed the period."); | ||
112 | } | ||
113 | info.exec_path = argv[optind + 8]; | ||
114 | info.argv = argv + optind + 8; | ||
115 | info.wait = wait; | ||
116 | if (migrate) { | ||
117 | ret = be_migrate_to(cpu); | ||
118 | if (ret < 0) | ||
119 | bail_out("could not migrate to target partition"); | ||
120 | } | ||
121 | /* create in src/task.c a new wrapper for the __launch_rt_task | ||
122 | * which takes the fraction and the cpus */ | ||
123 | ret = __create_rt_task_edffm(launch, &info, cpu, wcet, period, frac1, | ||
124 | frac2, cpu1, cpu2, class); | ||
125 | |||
126 | |||
127 | if (ret < 0) | ||
128 | bail_out("could not create rt child process"); | ||
129 | else if (verbose) | ||
130 | printf("%d\n", ret); | ||
131 | |||
132 | return 0; | ||
133 | } | ||
diff --git a/bin/rtspin_edffm.c b/bin/rtspin_edffm.c index 04dce0a..d28d028 100644 --- a/bin/rtspin_edffm.c +++ b/bin/rtspin_edffm.c | |||
@@ -201,7 +201,7 @@ int main(int argc, char** argv) | |||
201 | return 0; | 201 | return 0; |
202 | } | 202 | } |
203 | 203 | ||
204 | if (argc - optind < 3) | 204 | if (argc - optind < 9) |
205 | usage("Arguments missing."); | 205 | usage("Arguments missing."); |
206 | wcet_ms = atof(argv[optind + 0]); | 206 | wcet_ms = atof(argv[optind + 0]); |
207 | period_ms = atof(argv[optind + 1]); | 207 | period_ms = atof(argv[optind + 1]); |