Prioritize the SPI interrupt and gyro sending thread to fix timing issues.

Change-Id: I8f41084fcae5421f6eca585b9af606b418656b35
diff --git a/frc971/wpilib/gyro_sender.cc b/frc971/wpilib/gyro_sender.cc
index f410c19..5128110 100644
--- a/frc971/wpilib/gyro_sender.cc
+++ b/frc971/wpilib/gyro_sender.cc
@@ -20,10 +20,15 @@
 namespace frc971 {
 namespace wpilib {
 
-GyroSender::GyroSender() {}
 namespace chrono = ::std::chrono;
 using ::aos::monotonic_clock;
 
+GyroSender::GyroSender() {
+  PCHECK(system(
+             "ps -ef | grep '\\[spi0\\]' | awk '{print $1}' | xargs chrt -f -p "
+             "33") == 0);
+}
+
 void GyroSender::operator()() {
   ::aos::SetCurrentThreadName("Gyro");
 
@@ -47,7 +52,10 @@
   bool zeroed = false;
   double zero_offset = 0;
 
-  ::aos::time::PhasedLoop phased_loop(::aos::time::FromRate(kReadingRate));
+  ::aos::SetCurrentThreadRealtimePriority(33);
+
+  ::aos::time::PhasedLoop phased_loop(::aos::time::FromRate(kReadingRate),
+                                      chrono::milliseconds(4));
   // How many timesteps the next reading represents.
   int number_readings = 0;