Split process and thread counts in tasks meter

This commit is contained in:
Hisham Muhammad 2010-11-23 13:28:47 +00:00
parent d8e1480a27
commit 831538b0f9
5 changed files with 35 additions and 6 deletions

1
CRT.c
View File

@ -58,7 +58,6 @@ typedef enum ColorElements_ {
LED_COLOR,
UPTIME,
BATTERY,
TASKS_TOTAL,
TASKS_RUNNING,
SWAP,
PROCESS,

1
CRT.h
View File

@ -60,7 +60,6 @@ typedef enum ColorElements_ {
LED_COLOR,
UPTIME,
BATTERY,
TASKS_TOTAL,
TASKS_RUNNING,
SWAP,
PROCESS,

View File

@ -94,6 +94,8 @@ typedef struct ProcessList_ {
int cpuCount;
int totalTasks;
int userlandThreads;
int kernelThreads;
int runningTasks;
CPUData* cpus;
@ -635,6 +637,11 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
if (! ProcessList_readCmdlineFile(process, dirname, name))
goto errorReadingProcess;
}
if (Process_isKernelThread(process)) {
this->kernelThreads++;
} else {
this->userlandThreads++;
}
}
this->totalTasks++;
@ -772,6 +779,8 @@ void ProcessList_scan(ProcessList* this) {
}
this->totalTasks = 0;
this->userlandThreads = 0;
this->kernelThreads = 0;
this->runningTasks = 0;
ProcessList_processEntries(this, PROCDIR, NULL, period);

View File

@ -94,6 +94,8 @@ typedef struct ProcessList_ {
int cpuCount;
int totalTasks;
int userlandThreads;
int kernelThreads;
int runningTasks;
CPUData* cpus;

View File

@ -19,17 +19,37 @@ int TasksMeter_attributes[] = {
};
static void TasksMeter_setValues(Meter* this, char* buffer, int len) {
this->total = this->pl->totalTasks;
this->values[0] = this->pl->runningTasks;
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);
}
static void TasksMeter_display(Object* cast, RichString* out) {
Meter* this = (Meter*)cast;
ProcessList* pl = this->pl;
char buffer[20];
sprintf(buffer, "%d", (int)this->total);
sprintf(buffer, "%d", (int)(this->total - pl->userlandThreads - pl->kernelThreads));
RichString_write(out, CRT_colors[METER_VALUE], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " total, ");
int threadValueColor = CRT_colors[METER_VALUE];
int threadCaptionColor = CRT_colors[METER_TEXT];
if (pl->highlightThreads) {
threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME];
threadCaptionColor = CRT_colors[PROCESS_THREAD];
}
if (!pl->hideUserlandThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", ");
sprintf(buffer, "%d", (int)pl->userlandThreads);
RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " thr");
}
if (!pl->hideKernelThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", ");
sprintf(buffer, "%d", (int)pl->kernelThreads);
RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " kthr");
}
RichString_append(out, CRT_colors[METER_TEXT], "; ");
sprintf(buffer, "%d", (int)this->values[0]);
RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " running");