mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
Everywhere: Make tracking cpu usage independent from system ticks
This switches tracking CPU usage to more accurately measure time in user and kernel land using either the TSC or another time source. This will also come in handy when implementing a tickless kernel mode.
This commit is contained in:
parent
7e77a2ec40
commit
a635ff4e60
13 changed files with 174 additions and 85 deletions
|
@ -129,15 +129,15 @@ private:
|
|||
return false;
|
||||
|
||||
if (m_last_total_sum.has_value())
|
||||
scheduled_diff = all_processes->total_ticks_scheduled - m_last_total_sum.value();
|
||||
m_last_total_sum = all_processes->total_ticks_scheduled;
|
||||
scheduled_diff = all_processes->total_time_scheduled - m_last_total_sum.value();
|
||||
m_last_total_sum = all_processes->total_time_scheduled;
|
||||
|
||||
for (auto& it : all_processes.value().processes) {
|
||||
for (auto& jt : it.threads) {
|
||||
if (it.pid == 0)
|
||||
idle += jt.ticks_user + jt.ticks_kernel;
|
||||
idle += jt.time_user + jt.time_kernel;
|
||||
else
|
||||
busy += jt.ticks_user + jt.ticks_kernel;
|
||||
busy += jt.time_user + jt.time_kernel;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue