From: Jim Warner Date: Sat, 13 Jan 2018 06:00:00 +0000 (-0600) Subject: library: account for idle state ('I') threads in total X-Git-Tag: v4.0.0~653 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ede9ef79fba2b0815f6a8292733e1a82b98d6bf;p=procps-ng library: account for idle state ('I') threads in total With the documentation update in the commit referenced below, we should also account for such threads as they will already be represented in the task/thread totals. [ and do it in a way that might avoid future changes ] Reference(s): commit 91df65b9e778b9d7da7952d766e129f58423b807 Signed-off-by: Jim Warner --- diff --git a/proc/pids.c b/proc/pids.c index 0ee66b39..5f9ea1e8 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -961,17 +961,23 @@ static inline int pids_proc_tally ( case 'R': ++counts->running; break; + case 'D': // 'D' (disk sleep) case 'S': - case 'D': ++counts->sleeping; break; + case 't': // 't' (tracing stop) case 'T': ++counts->stopped; break; case 'Z': ++counts->zombied; break; - default: // keep gcc happy + default: + /* currently: 'I' (idle), + 'P' (parked), + 'X' (dead - actually 'dying' & probably never seen) + */ + ++counts->other; break; } ++counts->total; diff --git a/proc/pids.h b/proc/pids.h index 8fb489d1..96635b1d 100644 --- a/proc/pids.h +++ b/proc/pids.h @@ -183,7 +183,7 @@ struct pids_stack { struct pids_counts { int total; - int running, sleeping, stopped, zombied; + int running, sleeping, stopped, zombied, other; }; struct pids_fetch {