diff options
author | Nathan Scott <nathans@redhat.com> | 2021-04-07 15:19:18 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2021-04-07 15:19:18 +1000 |
commit | f3a37f9ef33cf5459acf1c5352f9c8104cce8806 (patch) | |
tree | c09f2df8264cc4075b72a55409ae261c021cda55 /ProcessList.c | |
parent | f16aa483dd36cfdb39e9d6d4238687178f2981e8 (diff) | |
parent | 356488aa53e8c0bedeb7641685d931c8900098c5 (diff) |
Merge branch 'smalinux-CtrTime'
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/ProcessList.c b/ProcessList.c index cd8ebd8a..6bc15611 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -10,11 +10,12 @@ in the source distribution for its full text. #include <assert.h> #include <stdlib.h> #include <string.h> +#include <sys/time.h> -#include "Compat.h" #include "CRT.h" #include "Hashtable.h" #include "Macros.h" +#include "Platform.h" #include "Vector.h" #include "XUtils.h" @@ -35,7 +36,7 @@ ProcessList* ProcessList_init(ProcessList* this, const ObjectClass* klass, Users // set later by platform-specific code this->cpuCount = 0; - this->scanTs = 0; + this->monotonicMs = 0; #ifdef HAVE_LIBHWLOC this->topologyOk = false; @@ -131,7 +132,7 @@ void ProcessList_add(ProcessList* this, Process* p) { p->processList = this; // highlighting processes found in first scan by first scan marked "far in the past" - p->seenTs = this->scanTs; + p->seenStampMs = this->monotonicMs; Vector_add(this->processes, p); Hashtable_put(this->processTable, p->pid, p); @@ -582,8 +583,6 @@ Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, } void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) { - struct timespec now; - // in pause mode only gather global data for meters (CPU/memory/...) if (pauseProcessUpdate) { ProcessList_goThroughEntries(this, true); @@ -604,31 +603,29 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) { this->runningTasks = 0; - // set scanTs + // set scan timestamp static bool firstScanDone = false; - if (!firstScanDone) { - this->scanTs = 0; + if (firstScanDone) { + Platform_gettime_monotonic(&this->monotonicMs); + } else { + this->monotonicMs = 0; firstScanDone = true; - } else if (Compat_clock_monotonic_gettime(&now) == 0) { - // save time in millisecond, so with a delay in deciseconds - // there are no irregularities - this->scanTs = 1000 * now.tv_sec + now.tv_nsec / 1000000; } ProcessList_goThroughEntries(this, false); for (int i = Vector_size(this->processes) - 1; i >= 0; i--) { Process* p = (Process*) Vector_get(this->processes, i); - if (p->tombTs > 0) { + if (p->tombStampMs > 0) { // remove tombed process - if (this->scanTs >= p->tombTs) { + if (this->monotonicMs >= p->tombStampMs) { ProcessList_remove(this, p); } } else if (p->updated == false) { // process no longer exists if (this->settings->highlightChanges && p->wasShown) { // mark tombed - p->tombTs = this->scanTs + 1000 * this->settings->highlightDelaySecs; + p->tombStampMs = this->monotonicMs + 1000 * this->settings->highlightDelaySecs; } else { // immediately remove ProcessList_remove(this, p); |