diff --git a/ProcessList.c b/ProcessList.c index b5a13f0a..f2cdcf94 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -281,7 +281,13 @@ Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, return proc; } -void ProcessList_scan(ProcessList* this) { +void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) { + + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) { + ProcessList_goThroughEntries(this, true); + return; + } // mark all process as "dirty" for (int i = 0; i < Vector_size(this->processes); i++) { @@ -295,7 +301,7 @@ void ProcessList_scan(ProcessList* this) { this->kernelThreads = 0; this->runningTasks = 0; - ProcessList_goThroughEntries(this); + ProcessList_goThroughEntries(this, false); for (int i = Vector_size(this->processes) - 1; i >= 0; i--) { Process* p = (Process*) Vector_get(this->processes, i); diff --git a/ProcessList.h b/ProcessList.h index 2dd2c8d2..07fe48bc 100644 --- a/ProcessList.h +++ b/ProcessList.h @@ -74,7 +74,7 @@ typedef struct ProcessList_ { ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidMatchList, uid_t userId); void ProcessList_delete(ProcessList* pl); -void ProcessList_goThroughEntries(ProcessList* pl); +void ProcessList_goThroughEntries(ProcessList* pl, bool pauseProcessUpdate); ProcessList* ProcessList_init(ProcessList* this, const ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); @@ -103,6 +103,6 @@ void ProcessList_rebuildPanel(ProcessList* this); Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, Process_New constructor); -void ProcessList_scan(ProcessList* this); +void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate); #endif diff --git a/ScreenManager.c b/ScreenManager.c index 2fce07de..bc5f66ac 100644 --- a/ScreenManager.c +++ b/ScreenManager.c @@ -105,9 +105,9 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi *timedOut = (newTime - *oldTime > this->settings->delay); *rescan = *rescan || *timedOut; if (newTime < *oldTime) *rescan = true; // clock was adjusted? - if (*rescan && !this->state->pauseProcessUpdate) { + if (*rescan) { *oldTime = newTime; - ProcessList_scan(pl); + ProcessList_scan(pl, this->state->pauseProcessUpdate); if (*sortTimeout == 0 || this->settings->treeView) { ProcessList_sort(pl); *sortTimeout = 1; diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c index 10d0697f..f6f08b50 100644 --- a/darwin/DarwinProcessList.c +++ b/darwin/DarwinProcessList.c @@ -144,7 +144,7 @@ void ProcessList_delete(ProcessList* this) { free(this); } -void ProcessList_goThroughEntries(ProcessList* super) { +void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { DarwinProcessList *dpl = (DarwinProcessList *)super; bool preExisting = true; struct kinfo_proc *ps; @@ -158,6 +158,10 @@ void ProcessList_goThroughEntries(ProcessList* super) { ProcessList_getVMStats(&dpl->vm_stats); openzfs_sysctl_updateArcStats(&dpl->zfs); + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) + return; + /* Get the time difference */ dpl->global_diff = 0; for(int i = 0; i < dpl->super.cpuCount; ++i) { diff --git a/darwin/DarwinProcessList.h b/darwin/DarwinProcessList.h index 58102d35..44a847dc 100644 --- a/darwin/DarwinProcessList.h +++ b/darwin/DarwinProcessList.h @@ -51,6 +51,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui void ProcessList_delete(ProcessList* this); -void ProcessList_goThroughEntries(ProcessList* super); +void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate); #endif diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 87f16069..e2a01270 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -358,7 +358,7 @@ char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int ja return jname; } -void ProcessList_goThroughEntries(ProcessList* this) { +void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) { DragonFlyBSDProcessList* dfpl = (DragonFlyBSDProcessList*) this; Settings* settings = this->settings; bool hideKernelThreads = settings->hideKernelThreads; @@ -368,6 +368,10 @@ void ProcessList_goThroughEntries(ProcessList* this) { DragonFlyBSDProcessList_scanCPUTime(this); DragonFlyBSDProcessList_scanJails(dfpl); + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) + return; + int count = 0; // TODO Kernel Threads seem to be skipped, need to figure out the correct flag diff --git a/dragonflybsd/DragonFlyBSDProcessList.h b/dragonflybsd/DragonFlyBSDProcessList.h index f35e60eb..47531297 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.h +++ b/dragonflybsd/DragonFlyBSDProcessList.h @@ -59,6 +59,6 @@ char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kpro char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid); -void ProcessList_goThroughEntries(ProcessList* this); +void ProcessList_goThroughEntries(ProcessList* this, pauseProcessUpdate); #endif diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 62969876..aec7e561 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -379,7 +379,7 @@ IGNORE_WCASTQUAL_END return jname; } -void ProcessList_goThroughEntries(ProcessList* this) { +void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) { FreeBSDProcessList* fpl = (FreeBSDProcessList*) this; Settings* settings = this->settings; bool hideKernelThreads = settings->hideKernelThreads; @@ -389,6 +389,10 @@ void ProcessList_goThroughEntries(ProcessList* this) { FreeBSDProcessList_scanMemoryInfo(this); FreeBSDProcessList_scanCPUTime(this); + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) + return; + int count = 0; struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count); diff --git a/freebsd/FreeBSDProcessList.h b/freebsd/FreeBSDProcessList.h index 75f71c12..c5866334 100644 --- a/freebsd/FreeBSDProcessList.h +++ b/freebsd/FreeBSDProcessList.h @@ -62,6 +62,6 @@ char* FreeBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, in char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc); -void ProcessList_goThroughEntries(ProcessList* this); +void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate); #endif diff --git a/htop.c b/htop.c index 7d1c1b16..8ff2baaf 100644 --- a/htop.c +++ b/htop.c @@ -303,9 +303,9 @@ int main(int argc, char** argv) { ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, &state, true); ScreenManager_add(scr, (Panel*) panel, -1); - ProcessList_scan(pl); + ProcessList_scan(pl, false); millisleep(75); - ProcessList_scan(pl); + ProcessList_scan(pl, false); ScreenManager_run(scr, NULL, NULL); diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 1ed13826..7e29e721 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -1382,7 +1382,7 @@ static void LinuxProcessList_scanCPUFrequency(LinuxProcessList* this) { scanCPUFreqencyFromCPUinfo(this); } -void ProcessList_goThroughEntries(ProcessList* super) { +void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { LinuxProcessList* this = (LinuxProcessList*) super; const Settings* settings = super->settings; @@ -1396,6 +1396,10 @@ void ProcessList_goThroughEntries(ProcessList* super) { if (settings->showCPUFrequency) LinuxProcessList_scanCPUFrequency(this); + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) + return; + struct timeval tv; gettimeofday(&tv, NULL); LinuxProcessList_recurseProcTree(this, PROCDIR, NULL, period, tv); diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h index 57bc9dc0..4427ccdf 100644 --- a/linux/LinuxProcessList.h +++ b/linux/LinuxProcessList.h @@ -101,6 +101,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui void ProcessList_delete(ProcessList* pl); -void ProcessList_goThroughEntries(ProcessList* super); +void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate); #endif diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c index 4b030707..83369494 100644 --- a/openbsd/OpenBSDProcessList.c +++ b/openbsd/OpenBSDProcessList.c @@ -340,10 +340,15 @@ static void OpenBSDProcessList_scanCPUTime(OpenBSDProcessList* this) { kernelCPUTimesToHtop(avg, this->cpus); } -void ProcessList_goThroughEntries(ProcessList* this) { +void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) { OpenBSDProcessList* opl = (OpenBSDProcessList*) this; OpenBSDProcessList_scanMemoryInfo(this); - OpenBSDProcessList_scanProcs(opl); OpenBSDProcessList_scanCPUTime(opl); + + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) + return; + + OpenBSDProcessList_scanProcs(opl); } diff --git a/openbsd/OpenBSDProcessList.h b/openbsd/OpenBSDProcessList.h index ab478571..3c3f1a33 100644 --- a/openbsd/OpenBSDProcessList.h +++ b/openbsd/OpenBSDProcessList.h @@ -45,6 +45,6 @@ void ProcessList_delete(ProcessList* this); char *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd); -void ProcessList_goThroughEntries(ProcessList* this); +void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate); #endif diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index 9662f830..2c59087d 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -374,10 +374,15 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * return 0; } -void ProcessList_goThroughEntries(ProcessList* this) { +void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) { SolarisProcessList_scanCPUTime(this); SolarisProcessList_scanMemoryInfo(this); SolarisProcessList_scanZfsArcstats(this); + + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) + return; + this->kernelThreads = 1; proc_walk(&SolarisProcessList_walkproc, this, PR_WALK_LWP); } diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h index c8a2d8d0..a138c3bf 100644 --- a/solaris/SolarisProcessList.h +++ b/solaris/SolarisProcessList.h @@ -60,6 +60,6 @@ void ProcessList_delete(ProcessList* pl); int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr); -void ProcessList_goThroughEntries(ProcessList* this); +void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate); #endif diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c index 40a24c28..33dd9fe8 100644 --- a/unsupported/UnsupportedProcessList.c +++ b/unsupported/UnsupportedProcessList.c @@ -24,8 +24,13 @@ void ProcessList_delete(ProcessList* this) { free(this); } -void ProcessList_goThroughEntries(ProcessList* super) { - bool preExisting = true; +void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { + + // in pause mode only gather global data for meters (CPU/memory/...) + if (pauseProcessUpdate) + return; + + bool preExisting = true; Process *proc; proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new); diff --git a/unsupported/UnsupportedProcessList.h b/unsupported/UnsupportedProcessList.h index 68c0ca7e..1c537713 100644 --- a/unsupported/UnsupportedProcessList.h +++ b/unsupported/UnsupportedProcessList.h @@ -11,6 +11,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui void ProcessList_delete(ProcessList* this); -void ProcessList_goThroughEntries(ProcessList* super); +void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate); #endif