summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-15 22:37:02 +0200
committerChristian Göttsche <cgzones@googlemail.com>2020-10-19 14:42:35 +0200
commit361877454fe56c95a995d5bdbb7eb70c21e39d62 (patch)
tree51f75a8ab66ece247dbbec3c673409028bdbec74 /freebsd
parent0db398d4c3472071b2814505242450cd8f831501 (diff)
Cache PAGE_SIZE
man:sysconf(3) states: The values obtained from these functions are system configuration constants. They do not change during the lifetime of a process.
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/FreeBSDProcessList.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c
index 62969876..b13b217b 100644
--- a/freebsd/FreeBSDProcessList.c
+++ b/freebsd/FreeBSDProcessList.c
@@ -19,6 +19,7 @@ in the source distribution for its full text.
#include <sys/sysctl.h>
#include <sys/user.h>
+#include "CRT.h"
#include "FreeBSDProcess.h"
#include "Macros.h"
#include "ProcessList.h"
@@ -60,8 +61,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
len = sizeof(pageSize);
if (sysctlbyname("vm.stats.vm.v_page_size", &pageSize, &len, NULL, 0) == -1) {
- pageSize = PAGE_SIZE;
- pageSizeKb = PAGE_SIZE_KB;
+ pageSize = CRT_pageSize;
+ pageSizeKb = CRT_pageSize;
} else {
pageSizeKb = pageSize / ONE_K;
}
@@ -446,12 +447,12 @@ void ProcessList_goThroughEntries(ProcessList* this) {
// from FreeBSD source /src/usr.bin/top/machine.c
proc->m_size = kproc->ki_size / 1024 / pageSizeKb;
proc->m_resident = kproc->ki_rssize;
- proc->percent_mem = (proc->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem) * 100.0;
+ proc->percent_mem = (proc->m_resident * pageSizeKb) / (double)(this->totalMem) * 100.0;
proc->nlwp = kproc->ki_numthreads;
proc->time = (kproc->ki_runtime + 5000) / 10000;
proc->percent_cpu = 100.0 * ((double)kproc->ki_pctcpu / (double)kernelFScale);
- proc->percent_mem = 100.0 * (proc->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem);
+ proc->percent_mem = 100.0 * (proc->m_resident * pageSizeKb) / (double)(this->totalMem);
/*
* TODO

© 2014-2024 Faster IT GmbH | imprint | privacy policy