aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Kenna <cjk@cs.unc.edu>2011-08-27 18:00:39 -0400
committerChristopher Kenna <cjk@cs.unc.edu>2011-08-27 18:00:39 -0400
commitf143b41261e8ae9cc48e8b68af2679ef332bd9e4 (patch)
treea7914d6ae181df324aa9f91269cf7d80d87d507e
parentd691d4545dc0594bc4bf13c4c07eeeaf73c3b232 (diff)
Changes to rtspin for mixed criticality (MC).
Add options to rtspin to set the criticality level using the -r flag. You must be using a kernel that has support for mixed criticality (has include/litmus/sched_mc.h for struct definitions, etc.).
-rw-r--r--Makefile2
-rw-r--r--bin/rtspin.c35
-rw-r--r--include/litmus.h3
-rw-r--r--src/syscalls.c5
4 files changed, 43 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index db94ffb..ae06ce5 100644
--- a/Makefile
+++ b/Makefile
@@ -154,7 +154,7 @@ arch/${include-${ARCH}}/include/asm/%.h: \
154 cp $< $@ 154 cp $< $@
155 155
156litmus-headers = include/litmus/rt_param.h include/litmus/unistd_32.h \ 156litmus-headers = include/litmus/rt_param.h include/litmus/unistd_32.h \
157 include/litmus/unistd_64.h 157 include/litmus/unistd_64.h include/litmus/sched_mc.h
158 158
159unistd-headers = \ 159unistd-headers = \
160 $(foreach file,${unistd-${ARCH}},arch/${include-${ARCH}}/include/asm/$(file)) 160 $(foreach file,${unistd-${ARCH}},arch/${include-${ARCH}}/include/asm/$(file))
diff --git a/bin/rtspin.c b/bin/rtspin.c
index ae76941..c5a2600 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -5,6 +5,9 @@
5#include <unistd.h> 5#include <unistd.h>
6#include <time.h> 6#include <time.h>
7#include <assert.h> 7#include <assert.h>
8#include <strings.h>
9
10#include <litmus/sched_mc.h>
8 11
9 12
10#include "litmus.h" 13#include "litmus.h"
@@ -21,6 +24,7 @@ static void usage(char *error) {
21 " rt_spin -l\n" 24 " rt_spin -l\n"
22 "\n" 25 "\n"
23 "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE]\n" 26 "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE]\n"
27 " [-r CRITICALITY = [a|b|c|d]]\n"
24 "\n" 28 "\n"
25 "WCET and PERIOD are milliseconds, DURATION is seconds.\n"); 29 "WCET and PERIOD are milliseconds, DURATION is seconds.\n");
26 exit(EXIT_FAILURE); 30 exit(EXIT_FAILURE);
@@ -161,7 +165,21 @@ static int job(double exec_time, double program_end)
161 } 165 }
162} 166}
163 167
164#define OPTSTR "p:c:wlveo:f:s:" 168enum crit_level str2crit(const char* str)
169{
170 if (0 == strncasecmp("a", str, 1))
171 return CRIT_LEVEL_A;
172 else if (0 == strncasecmp("b", str, 1))
173 return CRIT_LEVEL_B;
174 else if (0 == strncasecmp("c", str, 1))
175 return CRIT_LEVEL_C;
176 else if (0 == strncasecmp("d", str, 1))
177 return CRIT_LEVEL_D;
178 /* failure */
179 return NUM_CRIT_LEVELS;
180}
181
182#define OPTSTR "p:c:wlveo:f:s:r:"
165 183
166int main(int argc, char** argv) 184int main(int argc, char** argv)
167{ 185{
@@ -182,6 +200,8 @@ int main(int argc, char** argv)
182 double scale = 1.0; 200 double scale = 1.0;
183 task_class_t class = RT_CLASS_HARD; 201 task_class_t class = RT_CLASS_HARD;
184 int cur_job, num_jobs; 202 int cur_job, num_jobs;
203 enum crit_level crit = NUM_CRIT_LEVELS;
204 struct mc_task mc_task;
185 205
186 progname = argv[0]; 206 progname = argv[0];
187 207
@@ -214,6 +234,11 @@ int main(int argc, char** argv)
214 case 's': 234 case 's':
215 scale = atof(optarg); 235 scale = atof(optarg);
216 break; 236 break;
237 case 'r':
238 crit = str2crit(optarg);
239 if (NUM_CRIT_LEVELS == crit)
240 usage("Bad crit level.");
241 break;
217 case ':': 242 case ':':
218 usage("Argument missing."); 243 usage("Argument missing.");
219 break; 244 break;
@@ -281,6 +306,14 @@ int main(int argc, char** argv)
281 if (ret < 0) 306 if (ret < 0)
282 bail_out("could not setup rt task params"); 307 bail_out("could not setup rt task params");
283 308
309 if (NUM_CRIT_LEVELS != crit)
310 {
311 mc_task.crit = crit;
312 ret = set_rt_task_mc_param(gettid(), &mc_task);
313 if (ret < 0)
314 bail_out("could not setup rt mixed criticality params");
315 }
316
284 init_litmus(); 317 init_litmus();
285 318
286 ret = task_mode(LITMUS_RT_TASK); 319 ret = task_mode(LITMUS_RT_TASK);
diff --git a/include/litmus.h b/include/litmus.h
index 52435d8..b693e5c 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -26,6 +26,9 @@ int be_migrate_to(int target_cpu);
26int set_rt_task_param(pid_t pid, struct rt_task* param); 26int set_rt_task_param(pid_t pid, struct rt_task* param);
27int get_rt_task_param(pid_t pid, struct rt_task* param); 27int get_rt_task_param(pid_t pid, struct rt_task* param);
28 28
29struct mc_task;
30int set_rt_task_mc_param(pid_t pid, struct mc_task *param);
31
29/* setup helper */ 32/* setup helper */
30 33
31/* times are given in ms */ 34/* times are given in ms */
diff --git a/src/syscalls.c b/src/syscalls.c
index d800141..ef1ea17 100644
--- a/src/syscalls.c
+++ b/src/syscalls.c
@@ -88,3 +88,8 @@ int null_call(cycles_t *timestamp)
88{ 88{
89 return syscall(__NR_null_call, timestamp); 89 return syscall(__NR_null_call, timestamp);
90} 90}
91
92int set_rt_task_mc_param(pid_t pid, struct mc_task *param)
93{
94 return syscall(__NR_set_rt_task_mc_param, pid, param);
95}