Re: Processes vs Threads

From: David Brownell <db_at_argon.Eng.Sun.COM>
Date: 17 Nov 1994 19:02:51 GMT
Message-ID: <3ag9cr$dc7_at_engnews2.Eng.Sun.COM>


Casper H.S. Dik <casper_at_fwi.uva.nl> wrote:
>
> In Solaris the main difference between creating a new thread and fork is
> whether a new address space must be created or not.

There's actually more to fork() than that, and less to thr_create().

If you call thr_create() it normally just grabs a thread stack out of the cache, initializes some fields, and sticks it on the per-process run queue; typically not very many instructions, none of them in the kernel. It'll then be run by some handy processor when a kernel LWP next checks that queue.

Forking is quite a bit more heavy weight; it creates more new kernel resources than just a new address space. That might be the major cost of doing a fork(), but the other stuff is going to be more than the cost of juggling some user-mode data structures.

Casper's comments apply better to creating kernel LWPs (not to be confused with SunOS 4.x LWP library) than to Solaris threads.

-- 
David Brownell                        db_at_Eng.Sun.COM.
Distributed Object Management

main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}
Received on Thu Nov 17 1994 - 20:02:51 CET

Original text of this message