Expose thread list to users and track kthreads
This sets us up to use Top for configuring kthreads
Change-Id: I439bd21cf340457b85de8c4cbe1044fb8848e078
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/util/top.cc b/aos/util/top.cc
index 79ee2db..05e44f6 100644
--- a/aos/util/top.cc
+++ b/aos/util/top.cc
@@ -10,6 +10,8 @@
#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
+#define PF_KTHREAD 0x00200000
+
namespace aos::util {
namespace {
std::optional<std::string> ReadShortFile(std::string_view file_name) {
@@ -186,13 +188,16 @@
ProcessStartTime(*proc_stat);
auto reading_iter = readings_.find(pid);
if (reading_iter == readings_.end()) {
- reading_iter = readings_
- .insert(std::make_pair(
- pid, ProcessReadings{.name = proc_stat->name,
- .start_time = start_time,
- .cpu_percent = 0.0,
- .readings = {}}))
- .first;
+ reading_iter =
+ readings_
+ .insert(std::make_pair(
+ pid, ProcessReadings{.name = proc_stat->name,
+ .start_time = start_time,
+ .cpu_percent = 0.0,
+ .kthread = !!(proc_stat->kernel_flags &
+ PF_KTHREAD),
+ .readings = {}}))
+ .first;
}
ProcessReadings &process = reading_iter->second;
// The process associated with the PID has changed; reset the state.