From: Robert Love <rml@tech9.net>
To: Nick LeRoy <nleroy@cs.wisc.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Detecting threads vs processes with ps or /proc
Date: 06 Dec 2002 15:09:13 -0500 [thread overview]
Message-ID: <1039205353.1943.2191.camel@phantasy> (raw)
In-Reply-To: <200212061356.16022.nleroy@cs.wisc.edu>
On Fri, 2002-12-06 at 14:56, Nick LeRoy wrote:
> I was considerring doing something like this as well. From your
> experience, does it work reliably?
It never fails to detect threads (no false negatives).
It does sometimes detect child processes that forked but did not exec as
threads (false positives). The failure case is when a program forks,
does not call exec, and the children go on to execute the exact same
code (so they look and act just like threads, but they have unique
addresses spaces).
One thing to note: if you can modify the kernel and procps, you can just
export the value of task->mm out of /proc. It is a gross hack, and
perhaps a security issue, but that will work 100%. Same ->mm implies
thread.
> Do you need to apply a small 'fudge factor' (aka
> VMsize.1 ~= VMsize.2)?
No, they need to be exact. The stats are pulled from the same structure
in the kernel so they need to be perfect.
> > It is the default behavior. Flag `-m' turns it off.
> >
> > See thread_group() and flag_threads().
>
> I assume these are functions in the tools themselves?
Yep. Both ps and top have support. There is a patch on the website
that added the feature, so you can take a look at that.
Red Hat 8.0 has support in their version of procps 2.0.7, too.
Otherwise it was added in 2.0.8. The current version is 2.0.10.
We have a mailing list at procps-list@redhat.com where this sort of
discussion is welcome.
Robert Love
next prev parent reply other threads:[~2002-12-06 20:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-06 15:24 Detecting threads vs processes with ps or /proc Nick LeRoy
2002-12-06 19:48 ` Robert Love
2002-12-06 19:56 ` Nick LeRoy
2002-12-06 20:09 ` Robert Love [this message]
2002-12-09 16:27 ` Jeremy Fitzhardinge
2002-12-08 12:24 ` Gilad Ben-Yossef
-- strict thread matches above, loose matches on Subject: below --
2002-12-09 0:24 Albert D. Cahalan
2002-12-09 3:18 ` Nick LeRoy
2002-12-09 3:47 ` Robert Love
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1039205353.1943.2191.camel@phantasy \
--to=rml@tech9.net \
--cc=linux-kernel@vger.kernel.org \
--cc=nleroy@cs.wisc.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox