Re: Detecting threads vs processes with ps or /proc

Gilad Ben-Yossef
2002-12-08T12:18:24Z

On Fri, 2002-12-06 at 17:24, Nick LeRoy wrote:

>
> Our software (Condor) and some related software (Globus) is running on a
> number of systems around the world. Condor attempts to monitor the RAM usage
> of it's "user" (maybe "client" is a better word here) processes. If the
> client forks, we need to monitor the client and all of it's children, which
> really isn't difficult. The _problem_ is that if the client creates threads,
> it's impossible, from what we can tell, to tell the difference between
> separate threads and processes.
>
> So my question, I guess, is this. How can you tell, from user space, whether
> a group of processes are related as threads or through a "normal" child /
> parent relationship? The systems that we're running on currently are 2.2.19
> and 2.4.18/19.

There is another approach save for the one already discussed here, which
I have no idea how applicable it is in your case, but will produce 100%
reliable results without additional kernel support - track the processes
forks.

There are several ways you can go about it - there's the expensive (in
terms of CPU cycles) approach of using ptrace(2), the relativly painless
way of overriding the "default" calls to fork and friends via ld.so(8)
magical LD_PRELOAD that nevertheless requires you control the execution
of the "client" programs and even using a system call tracking module
such as syscall-tracker (http://syscalltrack.sf.net) which might not be
quite ready for use on a production system as of yet.

Hope this helps,
Gilad

--
Gilad Ben-Yossef <gilad@benyossef.com>
http://benyossef.com
"Denial really is a river in Eygept."