kernel/thread: Account for current run in fill_thread_info's CPU time handling.

Otherwise, if the thread is currently running, its runtime won't
be included in the returned statistics.
This commit is contained in:
Augustin Cavalier 2024-09-06 14:22:19 -04:00
parent 4e392e7f44
commit ace43da6f9

View File

@ -1222,6 +1222,13 @@ fill_thread_info(Thread *thread, thread_info *info, size_t size)
InterruptsSpinLocker threadTimeLocker(thread->time_lock);
info->user_time = thread->user_time;
info->kernel_time = thread->kernel_time;
if (thread->last_time != 0) {
const bigtime_t current = system_time() - thread->last_time;
if (thread->in_kernel)
info->kernel_time += current;
else
info->user_time += current;
}
}