Tuesday, May 10, 2016

Does totaling the threads of each process give the system's thread count?

Evidently not.

You can loop through each running process and total up the running threads in each, with some PowerShell, for instance:

(gwmi -Query "select threadcount from win32_process" | Select-Object -Property ThreadCount | Measure-Object ThreadCount -Sum).Sum

Interestingly, the result of that will match the result Performance Monitor (Perfmon) gives for the _Total instance of the Process → Thread Count counter, but is markedly less than Perfmon's value for Objects → Threads.

At first I guessed that kernel-mode drivers' threads weren't counted because of not being associated with a user-mode process, but it looks like driver threads appear as threads of the System process. Therefore, I don't know where the extra threads are coming from.

No comments:

Post a Comment