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.
This commit is contained in:
Christian Göttsche 2021-03-28 18:18:56 +02:00 committed by BenBE
parent 5afb57b49e
commit 8163b8164f
3 changed files with 21 additions and 27 deletions

6
CRT.c
View File

@ -118,6 +118,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[UPTIME] = A_BOLD | ColorPair(Cyan, Black), [UPTIME] = A_BOLD | ColorPair(Cyan, Black),
[BATTERY] = A_BOLD | ColorPair(Cyan, Black), [BATTERY] = A_BOLD | ColorPair(Cyan, Black),
[LARGE_NUMBER] = A_BOLD | ColorPair(Red, Black), [LARGE_NUMBER] = A_BOLD | ColorPair(Red, Black),
[METER_SHADOW] = A_BOLD | ColorPairGrayBlack,
[METER_TEXT] = ColorPair(Cyan, Black), [METER_TEXT] = ColorPair(Cyan, Black),
[METER_VALUE] = A_BOLD | ColorPair(Cyan, Black), [METER_VALUE] = A_BOLD | ColorPair(Cyan, Black),
[METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Black), [METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Black),
@ -209,6 +210,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[UPTIME] = A_BOLD, [UPTIME] = A_BOLD,
[BATTERY] = A_BOLD, [BATTERY] = A_BOLD,
[LARGE_NUMBER] = A_BOLD, [LARGE_NUMBER] = A_BOLD,
[METER_SHADOW] = A_DIM,
[METER_TEXT] = A_NORMAL, [METER_TEXT] = A_NORMAL,
[METER_VALUE] = A_BOLD, [METER_VALUE] = A_BOLD,
[METER_VALUE_ERROR] = A_BOLD, [METER_VALUE_ERROR] = A_BOLD,
@ -300,6 +302,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[UPTIME] = ColorPair(Yellow, White), [UPTIME] = ColorPair(Yellow, White),
[BATTERY] = ColorPair(Yellow, White), [BATTERY] = ColorPair(Yellow, White),
[LARGE_NUMBER] = ColorPair(Red, White), [LARGE_NUMBER] = ColorPair(Red, White),
[METER_SHADOW] = ColorPair(Blue, White),
[METER_TEXT] = ColorPair(Blue, White), [METER_TEXT] = ColorPair(Blue, White),
[METER_VALUE] = ColorPair(Black, White), [METER_VALUE] = ColorPair(Black, White),
[METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, White), [METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, White),
@ -391,6 +394,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[UPTIME] = ColorPair(Yellow, Black), [UPTIME] = ColorPair(Yellow, Black),
[BATTERY] = ColorPair(Yellow, Black), [BATTERY] = ColorPair(Yellow, Black),
[LARGE_NUMBER] = ColorPair(Red, Black), [LARGE_NUMBER] = ColorPair(Red, Black),
[METER_SHADOW] = A_BOLD | ColorPairGrayBlack,
[METER_TEXT] = ColorPair(Blue, Black), [METER_TEXT] = ColorPair(Blue, Black),
[METER_VALUE] = ColorPair(Black, Black), [METER_VALUE] = ColorPair(Black, Black),
[METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Black), [METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Black),
@ -482,6 +486,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[UPTIME] = A_BOLD | ColorPair(Yellow, Blue), [UPTIME] = A_BOLD | ColorPair(Yellow, Blue),
[BATTERY] = A_BOLD | ColorPair(Yellow, Blue), [BATTERY] = A_BOLD | ColorPair(Yellow, Blue),
[LARGE_NUMBER] = A_BOLD | ColorPair(Red, Blue), [LARGE_NUMBER] = A_BOLD | ColorPair(Red, Blue),
[METER_SHADOW] = ColorPair(Cyan, Blue),
[METER_TEXT] = ColorPair(Cyan, Blue), [METER_TEXT] = ColorPair(Cyan, Blue),
[METER_VALUE] = A_BOLD | ColorPair(Cyan, Blue), [METER_VALUE] = A_BOLD | ColorPair(Cyan, Blue),
[METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Blue), [METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Blue),
@ -573,6 +578,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[UPTIME] = ColorPair(Green, Black), [UPTIME] = ColorPair(Green, Black),
[BATTERY] = ColorPair(Green, Black), [BATTERY] = ColorPair(Green, Black),
[LARGE_NUMBER] = A_BOLD | ColorPair(Red, Black), [LARGE_NUMBER] = A_BOLD | ColorPair(Red, Black),
[METER_SHADOW] = A_BOLD | ColorPairGrayBlack,
[METER_TEXT] = ColorPair(Cyan, Black), [METER_TEXT] = ColorPair(Cyan, Black),
[METER_VALUE] = ColorPair(Green, Black), [METER_VALUE] = ColorPair(Green, Black),
[METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Black), [METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Black),

1
CRT.h
View File

@ -53,6 +53,7 @@ typedef enum ColorElements_ {
PANEL_SELECTION_FOLLOW, PANEL_SELECTION_FOLLOW,
PANEL_SELECTION_UNFOCUS, PANEL_SELECTION_UNFOCUS,
LARGE_NUMBER, LARGE_NUMBER,
METER_SHADOW,
METER_TEXT, METER_TEXT,
METER_VALUE, METER_VALUE,
METER_VALUE_ERROR, METER_VALUE_ERROR,

View File

@ -29,12 +29,8 @@ static void TasksMeter_updateValues(Meter* this) {
this->values[1] = pl->userlandThreads; this->values[1] = pl->userlandThreads;
this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads; this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
this->values[3] = MINIMUM(pl->runningTasks, pl->cpuCount); this->values[3] = MINIMUM(pl->runningTasks, pl->cpuCount);
if (pl->totalTasks > this->total) { this->total = pl->totalTasks;
this->total = pl->totalTasks;
}
if (pl->settings->hideKernelThreads) {
this->values[0] = 0;
}
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%d/%d", (int) this->values[3], (int) this->total); 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; const Settings* settings = this->pl->settings;
char buffer[20]; char buffer[20];
int processes = (int) this->values[2]; xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[2]);
xSnprintf(buffer, sizeof(buffer), "%d", processes);
RichString_writeAscii(out, CRT_colors[METER_VALUE], buffer); RichString_writeAscii(out, CRT_colors[METER_VALUE], buffer);
int threadValueColor = CRT_colors[METER_VALUE];
int threadCaptionColor = CRT_colors[METER_TEXT]; RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], ", ");
if (settings->highlightThreads) { xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]);
threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME]; RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[TASKS_RUNNING], buffer);
threadCaptionColor = CRT_colors[PROCESS_THREAD]; RichString_appendAscii(out, settings->hideUserlandThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], " thr");
}
if (!settings->hideUserlandThreads) { RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], ", ");
RichString_appendAscii(out, CRT_colors[METER_TEXT], ", "); xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]);
xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]); RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[TASKS_RUNNING], buffer);
RichString_appendAscii(out, threadValueColor, buffer); RichString_appendAscii(out, settings->hideKernelThreads ? CRT_colors[METER_SHADOW] : CRT_colors[METER_TEXT], " kthr");
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, CRT_colors[METER_TEXT], "; "); RichString_appendAscii(out, CRT_colors[METER_TEXT], "; ");
xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]); xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]);
RichString_appendAscii(out, CRT_colors[TASKS_RUNNING], buffer); RichString_appendAscii(out, CRT_colors[TASKS_RUNNING], buffer);