diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-26 21:25:45 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-26 21:37:30 +0100 |
commit | 712ae73581a1b44b36654824229f9cc475381c34 (patch) | |
tree | bab8587303236eabeef92afce5fe2cad35c9c635 /Kernel | |
parent | 86a9a52355905e4ac71730dba5c325498fd05177 (diff) | |
download | serenity-712ae73581a1b44b36654824229f9cc475381c34.zip |
Kernel: Expose per-thread information in /proc/all
Previously it was not possible to see what each thread in a process was
up to, or how much CPU it was consuming. This patch fixes that.
SystemMonitor and "top" now show threads instead of just processes.
"ps" is gonna need some more fixing, but it at least builds for now.
Fixes #66.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index bb7a86d7bc..928719b4fe 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -677,13 +677,11 @@ Optional<KBuffer> procfs$all(InodeIdentifier) auto build_process = [&](const Process& process) { auto process_object = array.add_object(); process_object.add("pid", process.pid()); - process_object.add("times_scheduled", process.main_thread().times_scheduled()); process_object.add("pgid", process.tty() ? process.tty()->pgid() : 0); process_object.add("pgp", process.pgid()); process_object.add("sid", process.sid()); process_object.add("uid", process.uid()); process_object.add("gid", process.gid()); - process_object.add("state", process.main_thread().state_string()); process_object.add("ppid", process.ppid()); process_object.add("nfds", process.number_of_open_file_descriptors()); process_object.add("name", process.name()); @@ -691,13 +689,21 @@ Optional<KBuffer> procfs$all(InodeIdentifier) process_object.add("amount_virtual", (u32)process.amount_virtual()); process_object.add("amount_resident", (u32)process.amount_resident()); process_object.add("amount_shared", (u32)process.amount_shared()); - process_object.add("ticks", process.main_thread().ticks()); - process_object.add("priority", to_string(process.main_thread().priority())); process_object.add("syscall_count", process.syscall_count()); process_object.add("inode_faults", process.inode_faults()); process_object.add("zero_faults", process.zero_faults()); process_object.add("cow_faults", process.cow_faults()); process_object.add("icon_id", process.icon_id()); + auto thread_array = process_object.add_array("threads"); + process.for_each_thread([&](const Thread& thread) { + auto thread_object = thread_array.add_object(); + thread_object.add("tid", thread.tid()); + thread_object.add("times_scheduled", thread.times_scheduled()); + thread_object.add("ticks", thread.ticks()); + thread_object.add("state", thread.state_string()); + thread_object.add("priority", to_string(thread.priority())); + return IterationDecision::Continue; + }); }; build_process(*Scheduler::colonel()); for (auto* process : processes) |