summaryrefslogtreecommitdiff
path: root/Userland/Utilities/w.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-07-14 12:05:59 -0600
committerAndreas Kling <kling@serenityos.org>2021-07-18 22:08:26 +0200
commit7e77a2ec40bc339f41e75aa9fdc6744df449612c (patch)
tree374e613b57185d92b6ce7903d8c5c6cd907f7b7a /Userland/Utilities/w.cpp
parentef85c4f7473e50c936a67a762c158833b9f0160a (diff)
downloadserenity-7e77a2ec40bc339f41e75aa9fdc6744df449612c.zip
Everywhere: Improve CPU usage calculation
As threads come and go, we can't simply account for how many time slices the threads at any given point may have been using. We need to also account for threads that have since disappeared. This means we also need to track how many time slices we have expired globally. However, because this doesn't account for context switches outside of the system timer tick values may still be under-reported. To solve this we will need to track more accurate time information on each context switch. This also fixes top's cpu usage calculation which was still based on the number of context switches. Fixes #6473
Diffstat (limited to 'Userland/Utilities/w.cpp')
-rw-r--r--Userland/Utilities/w.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Utilities/w.cpp b/Userland/Utilities/w.cpp
index 8768e74008..d09354594d 100644
--- a/Userland/Utilities/w.cpp
+++ b/Userland/Utilities/w.cpp
@@ -93,7 +93,7 @@ int main()
String what = "n/a";
- for (auto& process : process_statistics.value()) {
+ for (auto& process : process_statistics.value().processes) {
if (process.tty == tty && process.pid == process.pgid)
what = process.name;
}