aboutsummaryrefslogtreecommitdiffstats
path: root/darwin/DarwinProcessList.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2021-01-11 20:43:27 +0100
committerDaniel Lange <DLange@git.local>2021-01-11 20:43:27 +0100
commitc55320e9e2a8916e911bcd39ab37b79e3a7d03b2 (patch)
treed6be9a09fdf7d6dc155de3429a70697ee2bb43b0 /darwin/DarwinProcessList.c
parent65357c8c46154de4e4eca14075bfe5523bb5fc14 (diff)
downloaddebian_htop-c55320e9e2a8916e911bcd39ab37b79e3a7d03b2.tar.gz
debian_htop-c55320e9e2a8916e911bcd39ab37b79e3a7d03b2.tar.bz2
debian_htop-c55320e9e2a8916e911bcd39ab37b79e3a7d03b2.zip
New upstream version 3.0.5upstream/3.0.5
Diffstat (limited to 'darwin/DarwinProcessList.c')
-rw-r--r--darwin/DarwinProcessList.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c
index ae1efb1..4333710 100644
--- a/darwin/DarwinProcessList.c
+++ b/darwin/DarwinProcessList.c
@@ -7,7 +7,6 @@ in the source distribution for its full text.
#include "DarwinProcessList.h"
-#include <err.h>
#include <errno.h>
#include <libproc.h>
#include <stdbool.h>
@@ -21,6 +20,7 @@ in the source distribution for its full text.
#include "CRT.h"
#include "DarwinProcess.h"
+#include "Platform.h"
#include "ProcessList.h"
#include "zfs/openzfs_sysctl.h"
#include "zfs/ZfsArcStats.h"
@@ -71,14 +71,14 @@ static void ProcessList_getHostInfo(host_basic_info_data_t* p) {
mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT;
if (0 != host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)p, &info_size)) {
- CRT_fatalError("Unable to retrieve host info\n");
+ CRT_fatalError("Unable to retrieve host info");
}
}
static void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t* p) {
if (NULL != p && NULL != *p) {
if (0 != munmap(*p, vm_page_size)) {
- CRT_fatalError("Unable to free old CPU load information\n");
+ CRT_fatalError("Unable to free old CPU load information");
}
*p = NULL;
}
@@ -90,7 +90,7 @@ static unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t* p) {
// TODO Improving the accuracy of the load counts woule help a lot.
if (0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t*)p, &info_size)) {
- CRT_fatalError("Unable to retrieve CPU info\n");
+ CRT_fatalError("Unable to retrieve CPU info");
}
return cpu_count;
@@ -100,7 +100,7 @@ static void ProcessList_getVMStats(vm_statistics_t p) {
mach_msg_type_number_t info_size = HOST_VM_INFO_COUNT;
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)p, &info_size) != 0) {
- CRT_fatalError("Unable to retrieve VM statistics\n");
+ CRT_fatalError("Unable to retrieve VM statistics");
}
}
@@ -131,7 +131,7 @@ static struct kinfo_proc* ProcessList_getKInfoProcs(size_t* count) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
DarwinProcessList* this = xCalloc(1, sizeof(DarwinProcessList));
- ProcessList_init(&this->super, Class(Process), usersTable, pidMatchList, userId);
+ ProcessList_init(&this->super, Class(DarwinProcess), usersTable, pidMatchList, userId);
/* Initialize the CPU information */
this->super.cpuCount = ProcessList_allocateCPULoadInfo(&this->prev_load);
@@ -158,6 +158,11 @@ void ProcessList_delete(ProcessList* this) {
free(this);
}
+static double ticksToNanoseconds(const double ticks) {
+ const double nanos_per_sec = 1e9;
+ return (ticks / Platform_timebaseToNS) * (nanos_per_sec / (double) Platform_clockTicksPerSec);
+}
+
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
DarwinProcessList* dpl = (DarwinProcessList*)super;
bool preExisting = true;
@@ -185,6 +190,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
}
}
+ const double time_interval = ticksToNanoseconds(dpl->global_diff) / (double) dpl->super.cpuCount;
+
/* Clear the thread counts */
super->kernelThreads = 0;
super->userlandThreads = 0;
@@ -204,7 +211,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc = (DarwinProcess*)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, DarwinProcess_new);
DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], preExisting);
- DarwinProcess_setFromLibprocPidinfo(proc, dpl);
+ DarwinProcess_setFromLibprocPidinfo(proc, dpl, time_interval);
// Disabled for High Sierra due to bug in macOS High Sierra
bool isScanThreadSupported = ! ( CompareKernelVersion(17, 0, 0) >= 0 && CompareKernelVersion(17, 5, 0) < 0);

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