[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Threding (was: Configure can't find QT3)
From:       Andrew Sutton <ansutton () sep ! com>
Date:       2001-09-26 17:20:51
[Download RAW message or body]

On Wednesday 26 September 2001 12:01, Oswald Buddenhagen wrote:
> On Wed, Sep 26, 2001 at 12:44:40PM -0400, Jason Stephenson wrote:
> > On Linux, threading really makes no difference, since threads are
> > implemented identically to processes. So, doing a fork() and creating a
> > pthread are the same thing on Linux, as far as memory and system overhead
> > are concerned.
>
> sorry, but that's crap.
> the clone() syscall does create a new "process". the child process shares
> specified resources with the parent process, the others are copied. that
> means, that you could simulate a fork() by not specifying anything to
> share; that's in fact the way fork() is internally implemented. but for
> the threads we are currently talking about, one would specify (nearly)
> everything to share. the overhead of such a process is of course
> _significantly_ smaller than of a fork()ed process, because it has no
> own memory, own files, etc.  in numbers, the overhead of a new "thread"
> (as in posix meaning) is about 8 kb on an i386, whereas a fork()ed
> process can grow up to the same size as the parent process (if it would
> write-access all it's memory, as the memory duplication is implemented
> as copy-on-write).
>
> so far ... i hope not everything herein is wrong ... :)

sounds right to me - although you'd be an idiot to actually use the clone() 
call - unless you REALLY know what you're doing.

> Erm...I'm pretty sure that each thread gets its own stack.

you're right :) i was overgeneralizing. everything is share except the stack. 
pthread_create() creates a new process with the stack starting at the 
function that you tell it to.

andy
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic