Why are there many processes listed under the same title in htop?

62

11

Can anyone explain to me why there are sometimes 10 or 15 processes with the same title and "stats" listed in htop? I'm guessing there are multiple threads running - but that many of them obviously couldn't be running concurrently.

Is there any sort of performance hit taken if a process uses say, 15 non-concurrent threads vs. 10 non-concurrent threads?

javanix

Posted 2010-03-09T23:11:05.657

Reputation: 609

1http://unix.stackexchange.com/questions/10362/why-does-htop-show-more-process-than-ps – Ciro Santilli 新疆改造中心法轮功六四事件 – 2016-09-18T07:44:54.270

Answers

89

htop shows individual threads as separate processes by default, similarly to how ps -AL would. If you press capital H it will switch to only showing the main processes (pressing it again switches back). Each thread's summary information actually reflects the whole process, so they don't have separate memory counts etc. The threads will show R when active and S when not active, although because htop only refreshes every few seconds you can't actually monitor their activity easily that way, as thread switches happen much faster than that.

Performance of different threading models is complex, and beyond superuser.com - you need to detail particular issues if they arise rather than trying to guess :)

See http://groups.google.com/group/alt.os.linux.mandriva/browse_thread/thread/59c9f42e99b53663/2e6ddc78b2b85cf2?lnk=raot for more discussion of the same topic

Note that H is for user threads; for kernel threads a similar toggle key K exists, and both options are accessible under the settings menu - F2 then Display Options

David Fraser

Posted 2010-03-09T23:11:05.657

Reputation: 1 709

1K doesn't seem to work, but press F2 and go into setup, display options, tick the box hide userland threads. – Joshua D'Alton – 2013-04-17T11:28:39.813

7Oh, btw "H" uppercase might be what you meant. – Joshua D'Alton – 2013-04-17T11:29:52.723