Merge branch 'header_pause' of cgzones/htop

Continue to update generic data in paused mode
This commit is contained in:
Daniel Lange 2020-10-20 10:17:58 +02:00
commit 9f1a9ab2c2
18 changed files with 61 additions and 24 deletions

View File

@ -281,7 +281,13 @@ Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting,
return proc; 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" // mark all process as "dirty"
for (int i = 0; i < Vector_size(this->processes); i++) { for (int i = 0; i < Vector_size(this->processes); i++) {
@ -295,7 +301,7 @@ void ProcessList_scan(ProcessList* this) {
this->kernelThreads = 0; this->kernelThreads = 0;
this->runningTasks = 0; this->runningTasks = 0;
ProcessList_goThroughEntries(this); ProcessList_goThroughEntries(this, false);
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) { for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
Process* p = (Process*) Vector_get(this->processes, i); Process* p = (Process*) Vector_get(this->processes, i);

View File

@ -74,7 +74,7 @@ typedef struct ProcessList_ {
ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidMatchList, uid_t userId); ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* pl); 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); 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); 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 #endif

View File

@ -105,9 +105,9 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
*timedOut = (newTime - *oldTime > this->settings->delay); *timedOut = (newTime - *oldTime > this->settings->delay);
*rescan = *rescan || *timedOut; *rescan = *rescan || *timedOut;
if (newTime < *oldTime) *rescan = true; // clock was adjusted? if (newTime < *oldTime) *rescan = true; // clock was adjusted?
if (*rescan && !this->state->pauseProcessUpdate) { if (*rescan) {
*oldTime = newTime; *oldTime = newTime;
ProcessList_scan(pl); ProcessList_scan(pl, this->state->pauseProcessUpdate);
if (*sortTimeout == 0 || this->settings->treeView) { if (*sortTimeout == 0 || this->settings->treeView) {
ProcessList_sort(pl); ProcessList_sort(pl);
*sortTimeout = 1; *sortTimeout = 1;

View File

@ -144,7 +144,7 @@ void ProcessList_delete(ProcessList* this) {
free(this); free(this);
} }
void ProcessList_goThroughEntries(ProcessList* super) { void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
DarwinProcessList *dpl = (DarwinProcessList *)super; DarwinProcessList *dpl = (DarwinProcessList *)super;
bool preExisting = true; bool preExisting = true;
struct kinfo_proc *ps; struct kinfo_proc *ps;
@ -158,6 +158,10 @@ void ProcessList_goThroughEntries(ProcessList* super) {
ProcessList_getVMStats(&dpl->vm_stats); ProcessList_getVMStats(&dpl->vm_stats);
openzfs_sysctl_updateArcStats(&dpl->zfs); openzfs_sysctl_updateArcStats(&dpl->zfs);
// in pause mode only gather global data for meters (CPU/memory/...)
if (pauseProcessUpdate)
return;
/* Get the time difference */ /* Get the time difference */
dpl->global_diff = 0; dpl->global_diff = 0;
for(int i = 0; i < dpl->super.cpuCount; ++i) { for(int i = 0; i < dpl->super.cpuCount; ++i) {

View File

@ -51,6 +51,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
void ProcessList_delete(ProcessList* this); void ProcessList_delete(ProcessList* this);
void ProcessList_goThroughEntries(ProcessList* super); void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
#endif #endif

View File

@ -360,7 +360,7 @@ char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int ja
return jname; return jname;
} }
void ProcessList_goThroughEntries(ProcessList* this) { void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) {
DragonFlyBSDProcessList* dfpl = (DragonFlyBSDProcessList*) this; DragonFlyBSDProcessList* dfpl = (DragonFlyBSDProcessList*) this;
Settings* settings = this->settings; Settings* settings = this->settings;
bool hideKernelThreads = settings->hideKernelThreads; bool hideKernelThreads = settings->hideKernelThreads;
@ -370,6 +370,10 @@ void ProcessList_goThroughEntries(ProcessList* this) {
DragonFlyBSDProcessList_scanCPUTime(this); DragonFlyBSDProcessList_scanCPUTime(this);
DragonFlyBSDProcessList_scanJails(dfpl); DragonFlyBSDProcessList_scanJails(dfpl);
// in pause mode only gather global data for meters (CPU/memory/...)
if (pauseProcessUpdate)
return;
int count = 0; int count = 0;
// TODO Kernel Threads seem to be skipped, need to figure out the correct flag // TODO Kernel Threads seem to be skipped, need to figure out the correct flag

View File

@ -59,6 +59,6 @@ char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kpro
char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid); char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid);
void ProcessList_goThroughEntries(ProcessList* this); void ProcessList_goThroughEntries(ProcessList* this, pauseProcessUpdate);
#endif #endif

View File

@ -380,7 +380,7 @@ IGNORE_WCASTQUAL_END
return jname; return jname;
} }
void ProcessList_goThroughEntries(ProcessList* this) { void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) {
FreeBSDProcessList* fpl = (FreeBSDProcessList*) this; FreeBSDProcessList* fpl = (FreeBSDProcessList*) this;
Settings* settings = this->settings; Settings* settings = this->settings;
bool hideKernelThreads = settings->hideKernelThreads; bool hideKernelThreads = settings->hideKernelThreads;
@ -390,6 +390,10 @@ void ProcessList_goThroughEntries(ProcessList* this) {
FreeBSDProcessList_scanMemoryInfo(this); FreeBSDProcessList_scanMemoryInfo(this);
FreeBSDProcessList_scanCPUTime(this); FreeBSDProcessList_scanCPUTime(this);
// in pause mode only gather global data for meters (CPU/memory/...)
if (pauseProcessUpdate)
return;
int count = 0; int count = 0;
struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count); struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count);

View File

@ -62,6 +62,6 @@ char* FreeBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, in
char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc); char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc);
void ProcessList_goThroughEntries(ProcessList* this); void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate);
#endif #endif

4
htop.c
View File

@ -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* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, &state, true);
ScreenManager_add(scr, (Panel*) panel, -1); ScreenManager_add(scr, (Panel*) panel, -1);
ProcessList_scan(pl); ProcessList_scan(pl, false);
millisleep(75); millisleep(75);
ProcessList_scan(pl); ProcessList_scan(pl, false);
ScreenManager_run(scr, NULL, NULL); ScreenManager_run(scr, NULL, NULL);

View File

@ -1382,7 +1382,7 @@ static void LinuxProcessList_scanCPUFrequency(LinuxProcessList* this) {
scanCPUFreqencyFromCPUinfo(this); scanCPUFreqencyFromCPUinfo(this);
} }
void ProcessList_goThroughEntries(ProcessList* super) { void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
LinuxProcessList* this = (LinuxProcessList*) super; LinuxProcessList* this = (LinuxProcessList*) super;
const Settings* settings = super->settings; const Settings* settings = super->settings;
@ -1396,6 +1396,10 @@ void ProcessList_goThroughEntries(ProcessList* super) {
if (settings->showCPUFrequency) if (settings->showCPUFrequency)
LinuxProcessList_scanCPUFrequency(this); LinuxProcessList_scanCPUFrequency(this);
// in pause mode only gather global data for meters (CPU/memory/...)
if (pauseProcessUpdate)
return;
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
LinuxProcessList_recurseProcTree(this, PROCDIR, NULL, period, tv); LinuxProcessList_recurseProcTree(this, PROCDIR, NULL, period, tv);

View File

@ -101,6 +101,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
void ProcessList_delete(ProcessList* pl); void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* super); void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
#endif #endif

View File

@ -340,10 +340,15 @@ static void OpenBSDProcessList_scanCPUTime(OpenBSDProcessList* this) {
kernelCPUTimesToHtop(avg, this->cpus); kernelCPUTimesToHtop(avg, this->cpus);
} }
void ProcessList_goThroughEntries(ProcessList* this) { void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) {
OpenBSDProcessList* opl = (OpenBSDProcessList*) this; OpenBSDProcessList* opl = (OpenBSDProcessList*) this;
OpenBSDProcessList_scanMemoryInfo(this); OpenBSDProcessList_scanMemoryInfo(this);
OpenBSDProcessList_scanProcs(opl);
OpenBSDProcessList_scanCPUTime(opl); OpenBSDProcessList_scanCPUTime(opl);
// in pause mode only gather global data for meters (CPU/memory/...)
if (pauseProcessUpdate)
return;
OpenBSDProcessList_scanProcs(opl);
} }

View File

@ -45,6 +45,6 @@ void ProcessList_delete(ProcessList* this);
char *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd); 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 #endif

View File

@ -377,10 +377,15 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
return 0; return 0;
} }
void ProcessList_goThroughEntries(ProcessList* this) { void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) {
SolarisProcessList_scanCPUTime(this); SolarisProcessList_scanCPUTime(this);
SolarisProcessList_scanMemoryInfo(this); SolarisProcessList_scanMemoryInfo(this);
SolarisProcessList_scanZfsArcstats(this); SolarisProcessList_scanZfsArcstats(this);
// in pause mode only gather global data for meters (CPU/memory/...)
if (pauseProcessUpdate)
return;
this->kernelThreads = 1; this->kernelThreads = 1;
proc_walk(&SolarisProcessList_walkproc, this, PR_WALK_LWP); proc_walk(&SolarisProcessList_walkproc, this, PR_WALK_LWP);
} }

View File

@ -60,6 +60,6 @@ void ProcessList_delete(ProcessList* pl);
int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr); int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr);
void ProcessList_goThroughEntries(ProcessList* this); void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate);
#endif #endif

View File

@ -24,7 +24,12 @@ void ProcessList_delete(ProcessList* this) {
free(this); free(this);
} }
void ProcessList_goThroughEntries(ProcessList* super) { void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
// in pause mode only gather global data for meters (CPU/memory/...)
if (pauseProcessUpdate)
return;
bool preExisting = true; bool preExisting = true;
Process *proc; Process *proc;

View File

@ -11,6 +11,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
void ProcessList_delete(ProcessList* this); void ProcessList_delete(ProcessList* this);
void ProcessList_goThroughEntries(ProcessList* super); void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
#endif #endif