diff options
author | Daniel Lange <DLange@git.local> | 2021-08-02 15:21:07 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2021-08-02 15:21:07 +0200 |
commit | ed82ce6456f0f904a0ab2b346b85d7cf46df109c (patch) | |
tree | 1b02b20548da6dbcdf53872c3c99a3c013588fd1 /darwin/DarwinProcessList.c | |
parent | e341217fea844e1c45b7079146b9de7cb68e8c2a (diff) | |
parent | edf236f9fcf257c5266cead0c3bc45087d937e65 (diff) |
Merge branch 'cpu_count' of cgzones/htop
Diffstat (limited to 'darwin/DarwinProcessList.c')
-rw-r--r-- | darwin/DarwinProcessList.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c index 91d62c4a..8d14efe1 100644 --- a/darwin/DarwinProcessList.c +++ b/darwin/DarwinProcessList.c @@ -134,7 +134,9 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, H ProcessList_init(&this->super, Class(DarwinProcess), usersTable, dynamicMeters, pidMatchList, userId); /* Initialize the CPU information */ - this->super.cpuCount = ProcessList_allocateCPULoadInfo(&this->prev_load); + this->super.activeCPUs = ProcessList_allocateCPULoadInfo(&this->prev_load); + // TODO: support offline CPUs and hot swapping + this->super.existingCPUs = this->super.activeCPUs; ProcessList_getHostInfo(&this->host_info); ProcessList_allocateCPULoadInfo(&this->curr_load); @@ -184,13 +186,13 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { /* Get the time difference */ dpl->global_diff = 0; - for (unsigned int i = 0; i < dpl->super.cpuCount; ++i) { + for (unsigned int i = 0; i < dpl->super.existingCPUs; ++i) { for (size_t j = 0; j < CPU_STATE_MAX; ++j) { dpl->global_diff += dpl->curr_load[i].cpu_ticks[j] - dpl->prev_load[i].cpu_ticks[j]; } } - const double time_interval = ticksToNanoseconds(dpl->global_diff) / (double) dpl->super.cpuCount; + const double time_interval = ticksToNanoseconds(dpl->global_diff) / (double) dpl->super.activeCPUs; /* Clear the thread counts */ super->kernelThreads = 0; @@ -234,3 +236,12 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { free(ps); } + +bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) { + assert(id < super->existingCPUs); + + // TODO: support offline CPUs and hot swapping + (void) super; (void) id; + + return true; +} |