Add irq_affinity process for managing kthreads and irqs

This lets us configure irqs and kthreads away from the stock SCHED_FIFO,
priority 50 configuration reliably.  This is much more reliable in C++
than the old bash script which ran once.  This polls at 1 hz to handle
the case when the system changes.

Change-Id: I476d73b1fdb59e1796b5f8ac7ba18975d1874a48
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/util/top.cc b/aos/util/top.cc
index 05e44f6..8767cd4 100644
--- a/aos/util/top.cc
+++ b/aos/util/top.cc
@@ -224,6 +224,10 @@
       process.cpu_percent = 0.0;
     }
   }
+
+  if (on_reading_update_) {
+    on_reading_update_();
+  }
 }
 
 flatbuffers::Offset<ProcessInfo> Top::InfoForProcess(
diff --git a/aos/util/top.h b/aos/util/top.h
index 8698bc1..314e6bd 100644
--- a/aos/util/top.h
+++ b/aos/util/top.h
@@ -121,6 +121,10 @@
   // to track every single process on the system, so that we can sort them).
   void set_track_top_processes(bool track_all) { track_all_ = track_all; }
 
+  void set_on_reading_update(std::function<void()> fn) {
+    on_reading_update_ = std::move(fn);
+  }
+
   // Specify a set of individual processes to track statistics for.
   // This can be changed at run-time, although it may take up to kSamplePeriod
   // to have full statistics on all the relevant processes, since we need at
@@ -159,6 +163,8 @@
   bool track_all_ = false;
 
   std::map<pid_t, ProcessReadings> readings_;
+
+  std::function<void()> on_reading_update_;
 };
 
 }  // namespace aos::util