Actually limit the % RT time
starter.sh runs as lvuser, which doesn't have enough permission.
starter runs using the suid bit, and runs as admin. Do it there
instead.
Change-Id: Ie3296960ecd4889fa0dc19ab38e65597c4b7b426
diff --git a/aos/starter/starter.cc b/aos/starter/starter.cc
index 501530c..4bfb3d2 100644
--- a/aos/starter/starter.cc
+++ b/aos/starter/starter.cc
@@ -751,6 +751,13 @@
// This is in here instead of starter.sh because starter.sh doesn't run with
// permissions on a roboRIO.
AOS_CHECK(system("echo 0 > /proc/sys/vm/overcommit_memory") == 0);
+
+ // Configure throttling so we reserve 5% of the CPU for non-rt work.
+ // This makes things significantly more stable when work explodes.
+ // This is in here instead of starter.sh for the same reasons, starter is suid
+ // and runs as admin, so this actually works.
+ AOS_CHECK(system("/sbin/sysctl -w kernel.sched_rt_period_us=1000000") == 0);
+ AOS_CHECK(system("/sbin/sysctl -w kernel.sched_rt_runtime_us=950000") == 0);
#endif
libevent_base = EventBaseUniquePtr(event_base_new());
diff --git a/aos/starter/starter.sh b/aos/starter/starter.sh
index 87f58a4..e140351 100755
--- a/aos/starter/starter.sh
+++ b/aos/starter/starter.sh
@@ -4,11 +4,6 @@
if [[ "$(hostname)" == "roboRIO"* ]]; then
ROBOT_CODE="/home/admin/robot_code"
- # Configure throttling so we reserve 5% of the CPU for non-rt work.
- # This makes things significantly more stable.
- echo 950000 > /proc/sys/kernel/sched_rt_runtime_us
- echo 1000000 > /proc/sys/kernel/sched_rt_period_us
-
ln -s /var/local/natinst/log/FRC_UserProgram.log /tmp/FRC_UserProgram.log
ln -s /var/local/natinst/log/FRC_UserProgram.log "${ROBOT_CODE}/FRC_UserProgram.log"
elif [[ "$(hostname)" == "pi-"* ]]; then