aboutsummaryrefslogtreecommitdiffstats
path: root/TasksMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
commitff9409b1737627857eb47f64f536a3f66b6a09a4 (patch)
tree61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /TasksMeter.c
parentf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff)
downloaddebian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'TasksMeter.c')
-rw-r--r--TasksMeter.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/TasksMeter.c b/TasksMeter.c
index 22a125e..f3764d6 100644
--- a/TasksMeter.c
+++ b/TasksMeter.c
@@ -7,7 +7,7 @@ in the source distribution for its full text.
#include "TasksMeter.h"
-#include "ProcessList.h"
+#include "Platform.h"
#include "CRT.h"
/*{
@@ -15,42 +15,53 @@ in the source distribution for its full text.
}*/
int TasksMeter_attributes[] = {
- TASKS_RUNNING
+ CPU_KERNEL, PROCESS_THREAD, PROCESS, TASKS_RUNNING
};
static void TasksMeter_setValues(Meter* this, char* buffer, int len) {
ProcessList* pl = this->pl;
- this->total = pl->totalTasks;
- this->values[0] = pl->runningTasks;
- snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total);
+ this->values[0] = pl->kernelThreads;
+ this->values[1] = pl->userlandThreads;
+ this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
+ this->values[3] = pl->runningTasks;
+ if (pl->totalTasks > this->total) {
+ this->total = pl->totalTasks;
+ }
+ if (this->pl->settings->hideKernelThreads) {
+ this->values[0] = 0;
+ }
+ snprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
}
static void TasksMeter_display(Object* cast, RichString* out) {
Meter* this = (Meter*)cast;
- ProcessList* pl = this->pl;
+ Settings* settings = this->pl->settings;
char buffer[20];
- sprintf(buffer, "%d", (int)(this->total - pl->userlandThreads - pl->kernelThreads));
+
+ int processes = (int) this->values[2];
+
+ sprintf(buffer, "%d", processes);
RichString_write(out, CRT_colors[METER_VALUE], buffer);
int threadValueColor = CRT_colors[METER_VALUE];
int threadCaptionColor = CRT_colors[METER_TEXT];
- if (pl->highlightThreads) {
+ if (settings->highlightThreads) {
threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME];
threadCaptionColor = CRT_colors[PROCESS_THREAD];
}
- if (!pl->hideUserlandThreads) {
+ if (!settings->hideUserlandThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", ");
- sprintf(buffer, "%d", (int)pl->userlandThreads);
+ sprintf(buffer, "%d", (int)this->values[1]);
RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " thr");
}
- if (!pl->hideKernelThreads) {
+ if (!settings->hideKernelThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", ");
- sprintf(buffer, "%d", (int)pl->kernelThreads);
+ sprintf(buffer, "%d", (int)this->values[0]);
RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " kthr");
}
RichString_append(out, CRT_colors[METER_TEXT], "; ");
- sprintf(buffer, "%d", (int)this->values[0]);
+ sprintf(buffer, "%d", (int)this->values[3]);
RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " running");
}
@@ -64,6 +75,7 @@ MeterClass TasksMeter_class = {
.setValues = TasksMeter_setValues,
.defaultMode = TEXT_METERMODE,
.total = 100.0,
+ .maxItems = 4,
.attributes = TasksMeter_attributes,
.name = "Tasks",
.uiName = "Task counter",

© 2014-2024 Faster IT GmbH | imprint | privacy policy