summaryrefslogtreecommitdiffstats
path: root/TasksMeter.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-03-28 18:18:56 +0200
committerBenBE <BenBE@geshi.org>2021-03-31 00:27:14 +0200
commit8163b8164ff90681cf1400ab540beb8fffdeb60f (patch)
tree020104435c1d2736a03863ad1b8e4999127034d3 /TasksMeter.c
parent5afb57b49e7888adfb7e6cf522ca431785c6f5f5 (diff)
TaskMeter: always show number of threads
Always show the number of kernel and userland threads, even when they are disabled to not be shown in the process list. The data is already available and might improve understanding the system utilization. Use a shadow color in case the kind of thread is hidden, else the normal meter one.
Diffstat (limited to 'TasksMeter.c')
-rw-r--r--TasksMeter.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/TasksMeter.c b/TasksMeter.c
index 7b649b0c..9c6b9cd8 100644
--- a/TasksMeter.c
+++ b/TasksMeter.c
@@ -29,12 +29,8 @@ static void TasksMeter_updateValues(Meter* this) {
this->values[1] = pl->userlandThreads;
this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
this->values[3] = MINIMUM(pl->runningTasks, pl->cpuCount);
- if (pl->totalTasks > this->total) {
- this->total = pl->totalTasks;
- }
- if (pl->settings->hideKernelThreads) {
- this->values[0] = 0;
- }
+ this->total = pl->totalTasks;
+
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%d/%d", (int) this->values[3], (int) this->total);
}
@@ -43,28 +39,19 @@ static void TasksMeter_display(const Object* cast, RichString* out) {
const Settings* settings = this->pl->settings;
char buffer[20];
- int processes = (int) this->values[2];
-
- xSnprintf(buffer, sizeof(buffer), "%d", processes);
+ xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[2]);
RichString_writeAscii(out, CRT_colors[METER_VALUE], buffer);
- int threadValueColor = CRT_colors[METER_VALUE];
- int threadCaptionColor = CRT_colors[METER_TEXT];
- if (settings->highlightThreads) {
- threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME];
- threadCaptionColor = CRT_colors[PROCESS_THREAD];
- }
- if (!settings->hideUserlandThreads) {
- RichString_appendAscii(out, CRT_colors[METER_TEXT], ", ");
- xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]);
- RichString_appendAscii(out, threadValueColor, buffer);
- RichString_appendAscii(out, threadCaptionColor, " thr");
- }
- if (!settings->hideKernelThreads) {
- RichString_appendAscii(out, CRT_colors[METER_TEXT], ", ");
- xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]);
- RichString_appendAscii(out, threadValueColor, buffer);
- RichString_appendAscii(out, threadCaptionColor, " kthr");
- }
+
+ RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], ", ");
+ xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]);
+ RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[TASKS_RUNNING], buffer);
+ RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], " thr");
+
+ RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], ", ");
+ xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]);
+ RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[TASKS_RUNNING], buffer);
+ RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], " kthr");
+
RichString_appendAscii(out, CRT_colors[METER_TEXT], "; ");
xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]);
RichString_appendAscii(out, CRT_colors[TASKS_RUNNING], buffer);

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