diff options
author | Nathan Scott <nathans@redhat.com> | 2023-05-02 09:02:22 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2023-05-08 13:06:07 +1000 |
commit | 0bdade1b6cb40c5bd374a93ac0489058a7421bb5 (patch) | |
tree | 0e0225f7dbf6867402c5ed3481a705d01941f42e /darwin/Platform.c | |
parent | e4ebe18b67c366d367231a1123b057c82018cf5b (diff) |
Introduce Machine class for host-specific info (split from ProcessList)
First stage in sanitizing the process list structure so that htop
can support other types of lists too (cgroups, filesystems, ...),
in the not-too-distant future.
This introduces struct Machine for system-wide information while
keeping process-list information in ProcessList (now much less).
Next step is to propogate this separation into each platform, to
match these core changes.
Diffstat (limited to 'darwin/Platform.c')
-rw-r--r-- | darwin/Platform.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/darwin/Platform.c b/darwin/Platform.c index 20bfec26..71d08247 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -233,13 +233,13 @@ int Platform_getMaxPid(void) { } static double Platform_setCPUAverageValues(Meter* mtr) { - const ProcessList* dpl = mtr->pl; - unsigned int activeCPUs = dpl->activeCPUs; + const Machine* host = mtr->host; + unsigned int activeCPUs = host->activeCPUs; double sumNice = 0.0; double sumNormal = 0.0; double sumKernel = 0.0; double sumPercent = 0.0; - for (unsigned int i = 1; i <= dpl->existingCPUs; i++) { + for (unsigned int i = 1; i <= host->existingCPUs; i++) { sumPercent += Platform_setCPUValues(mtr, i); sumNice += mtr->values[CPU_METER_NICE]; sumNormal += mtr->values[CPU_METER_NORMAL]; @@ -257,7 +257,7 @@ double Platform_setCPUValues(Meter* mtr, unsigned int cpu) { return Platform_setCPUAverageValues(mtr); } - const DarwinProcessList* dpl = (const DarwinProcessList*)mtr->pl; + const DarwinProcessList* dpl = (const DarwinProcessList*)mtr->host->pl; const processor_cpu_load_info_t prev = &dpl->prev_load[cpu - 1]; const processor_cpu_load_info_t curr = &dpl->curr_load[cpu - 1]; double total = 0; @@ -286,7 +286,8 @@ double Platform_setCPUValues(Meter* mtr, unsigned int cpu) { } void Platform_setMemoryValues(Meter* mtr) { - const DarwinProcessList* dpl = (const DarwinProcessList*)mtr->pl; + const Machine* host = mtr->host; + const DarwinProcessList* dpl = (const DarwinProcessList*) host->pl; const struct vm_statistics* vm = &dpl->vm_stats; double page_K = (double)vm_page_size / (double)1024; @@ -312,13 +313,13 @@ void Platform_setSwapValues(Meter* mtr) { } void Platform_setZfsArcValues(Meter* this) { - const DarwinProcessList* dpl = (const DarwinProcessList*) this->pl; + const DarwinProcessList* dpl = (const DarwinProcessList*) this->host->pl; ZfsArcMeter_readStats(this, &(dpl->zfs)); } void Platform_setZfsCompressedArcValues(Meter* this) { - const DarwinProcessList* dpl = (const DarwinProcessList*) this->pl; + const DarwinProcessList* dpl = (const DarwinProcessList*) this->host->pl; ZfsCompressedArcMeter_readStats(this, &(dpl->zfs)); } |