summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas C. Villa Real <lucasvr@gmail.com>2018-01-23 13:41:22 -0200
committerHisham Muhammad <hisham@gobolinux.org>2018-01-23 14:11:47 -0200
commitad99187680585bf66f9de4f617e897dada8767f7 (patch)
treea15c4ad723ef60c18614835b5bb8b8167b65adff
parentb7b66b76a5f01ac570d537d27a7e156af248d6f4 (diff)
htop scans /proc to determine how many running tasks exist. Since that
operation is not possible to be conducted in an atomic fashion, task scheduling effects can lead to a count greater than the number of actual processors; this is more easily noticed on machines with several CPUs and under heavy workload. This patch simply adds an upper bound on cpuCount to guarantee consistent reports of the number of running tasks at any given time.
-rw-r--r--TasksMeter.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/TasksMeter.c b/TasksMeter.c
index 6a08d885..f56c8613 100644
--- a/TasksMeter.c
+++ b/TasksMeter.c
@@ -23,7 +23,7 @@ static void TasksMeter_updateValues(Meter* this, char* buffer, int len) {
this->values[0] = pl->kernelThreads;
this->values[1] = pl->userlandThreads;
this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
- this->values[3] = pl->runningTasks;
+ this->values[3] = MIN(pl->runningTasks, pl->cpuCount);
if (pl->totalTasks > this->total) {
this->total = pl->totalTasks;
}

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