From 5afb57b49e7888adfb7e6cf522ca431785c6f5f5 Mon Sep 17 00:00:00 2001 From: Alexander Nedotsukov Date: Tue, 30 Mar 2021 10:58:09 +0300 Subject: [PATCH] FreeBSD: improve actual processor calculation logic --- freebsd/FreeBSDProcessList.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 628956d1..2e937669 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -572,7 +572,11 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { proc->percent_cpu = 100.0 * ((double)kproc->ki_pctcpu / (double)kernelFScale); proc->percent_mem = 100.0 * proc->m_resident / (double)(super->totalMem); - proc->processor = kproc->ki_lastcpu; + if (kproc->ki_stat == SRUN && kproc->ki_oncpu != NOCPU) { + proc->processor = kproc->ki_oncpu; + } else { + proc->processor = kproc->ki_lastcpu; + } proc->majflt = kproc->ki_cow;