瀏覽代碼

SystemMonitor: Fix calculation of CPU percentage

This commit addresses an issue when 'Zombie' threads are
included in CPU % calculation. This caused negative
time_scheduled_diff, resulting in a data type overflow.
Michal Grich 2 年之前
父節點
當前提交
2e9fcc17a0
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      Userland/Applications/SystemMonitor/ProcessModel.cpp

+ 3 - 0
Userland/Applications/SystemMonitor/ProcessModel.cpp

@@ -574,6 +574,9 @@ void ProcessModel::update()
             tids_to_remove.append(it.key);
             continue;
         }
+        if (it.value->current_state.state == "Zombie") {
+            continue;
+        }
         auto& thread = *it.value;
         u64 time_scheduled_diff = (thread.current_state.time_user + thread.current_state.time_kernel)
             - (thread.previous_state.time_user + thread.previous_state.time_kernel);