Convert control loop tests over to simulated event loop
This makes it so that we properly only use ShmEventLoop for running in
realtime on a robot. Very nice.
Change-Id: I46b770b336f59e08cfaf28511b3bd5689f72fff1
diff --git a/aos/init.cc b/aos/init.cc
index aa609ec..8ce70ea 100644
--- a/aos/init.cc
+++ b/aos/init.cc
@@ -120,15 +120,19 @@
GoRT(relative_priority);
}
+void InitRT() {
+ LockAllMemory();
+
+ // Only let rt processes run for 3 seconds straight.
+ SetSoftRLimit(RLIMIT_RTTIME, 3000000, true);
+
+ // Allow rt processes up to priority 40.
+ SetSoftRLimit(RLIMIT_RTPRIO, 40, false);
+}
+
void GoRT(int relative_priority) {
if (ShouldBeRealtime()) {
- LockAllMemory();
-
- // Only let rt processes run for 3 seconds straight.
- SetSoftRLimit(RLIMIT_RTTIME, 3000000, true);
-
- // Allow rt processes up to priority 40.
- SetSoftRLimit(RLIMIT_RTPRIO, 40, false);
+ InitRT();
// Set our process to the appropriate priority.
struct sched_param param;
@@ -137,9 +141,10 @@
PDie("%s-init: setting SCHED_FIFO failed", program_invocation_short_name);
}
} else {
- fprintf(stderr, "%s not doing realtime initialization because environment"
- " variable %s is set\n", program_invocation_short_name,
- kNoRealtimeEnvironmentVariable);
+ fprintf(stderr,
+ "%s not doing realtime initialization because environment"
+ " variable %s is set\n",
+ program_invocation_short_name, kNoRealtimeEnvironmentVariable);
printf("no realtime for %s. see stderr\n", program_invocation_short_name);
}