[ale] differentiating processes from threads

John Wells jb at sourceillustrated.com
Tue Apr 2 04:32:55 EST 2002


Hmmm...

Ok, so to test this we should be able to:

perl -e 'fork();<STDIN>;'

Shouldn't this do a true fork?  If so, then look at the output of:

ps -eo pid,pgid,flags,user,args | grep perl

30213 30213 000 jbw      perl -e fork();<STDIN>;
30214 30213 040 jbw      perl -e fork();<STDIN>;

The second process still has the FORKNOEXEC flags set?!?

Thanks for the help,

John

---------  Original message --------
From: Danny Cox <danscox at mindspring.com>
To: ale at ale.org
To: John Wells <jb at sourceillustrated.com>
CC: ALE Mailing List <ale at ale.org>
Subject: Re: [ale] differentiating processes from threads
Date: 04-02-02 13:37

> John,

On Tue, 2002-04-02 at 03:17, John Wells wrote:
&gt; Awhile back I sent out a message regarding mozilla's apparent spawning
of
&gt; multiple processes with large memory footprints.  Someone corrected me,
&gt; stating that these were actually threads using shared memory and were
just
&gt; reported by top and ps -ef as seperate processes.  They forwarded a ps
&gt; string that returned some obscure indication of the fact that they were
&gt; threads.
&gt;
&gt; I find myself in a situation where I need to be able to differentiate
&gt; processes from threads.  Can anyone help me out?  The previously
mentioned
&gt; ps string would do, but I wonder what other ways exist?

Okay, here is that previous message.  I hope it'll do!

On Fri, Feb 08, 2002 at 07:53:43AM -0500, Danny Cox wrote:
&gt;       My mozilla(-bin) is currently using 13024 K of mem.  Large, but
&gt; not too bad (sheesh! who remembers when 65k was all the addresses
&gt; ya got? ;-).

I did find one (small) distinction using the esoteric command:

ps -eo pid,flags,user,args

the mozillas look like this:

1492 000 danny    /home/danny/src/mozilla/mozilla-9.8/mozilla-bin
1494 040 danny    /home/danny/src/mozilla/mozilla-9.8/mozilla-bin
1495 040 danny    /home/danny/src/mozilla/mozilla-9.8/mozilla-bin
1496 040 danny    /home/danny/src/mozilla/mozilla-9.8/mozilla-bin
1597 040 danny    /home/danny/src/mozilla/mozilla-9.8/mozilla-bin

The '040' in the 'flags' field means 'process forked but didn't
exec', which while true, doesn't mean exactly 'process is a thread'.

The main problem is that on Linux, a thread *is* a process.  It simply
shares it's data space and file descriptors with at least one other
process.  See 'man 2 clone' for more info.

Hope this helps!

--
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.

Danny


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list