Re: Detecting threads vs processes with ps or /proc

Gilad Ben-Yossef (gilad@benyossef.com)
08 Dec 2002 14:24:42 +0200


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."

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/