Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
* FAQ Request
@ 1998-06-10  4:00 robj
  1998-06-11  4:00 ` N Madden
  0 siblings, 1 reply; 3+ messages in thread
From: robj @ 1998-06-10  4:00 UTC (permalink / raw)



Good morning:

I am new to this group, and before asking questions which are probably
common, could someone direct me to the location of the FAQs?

Thanks.

Rob Janzen

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading



^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: Threads better than forks?
@ 1993-10-12  2:39 Thuan Q. Pham
  1993-10-14 15:23 ` FAQ request Steven Wayne Hudson
  0 siblings, 1 reply; 3+ messages in thread
From: Thuan Q. Pham @ 1993-10-12  2:39 UTC (permalink / raw)


In article <mauney.750363918@adm> mauney@adm.csc.ncsu.edu (Jon Mauney) writes:

>   a) Fork is usually a fairly heavyweight operation.  Creating a thread
>     should be fairly fast

Yes, forking a process is much more expensive than spawning thread because
of the overhead.  To create a process, the system must set up the address
space and other system resources (memory pages, file descriptors, etc. etc..)

In a multithreaded process (Mach calls it "task"), threads within the same
process share all of the process's resources, so creating a thread is a
cheap operation: setting up the thread running context (program counter,
registers set, etc...).  It inherits the rest from the parent process.
And since threads share the process's resources, communication between them
can be done very naturally and efficiently with shared memory.

>     .... Also, scheduling of threads within a process doesn't
>     require a context switch, and there takes much less time than
>     switching between two processes.

Well, whether context switching is required for thread scheduling depends
on what kind of threads we're talking about.  If it's kernel thread,
switching between threads DOES require a context switch.  If it's
user-level thread, then the user-thread run-time library schedules the
threads, and the kernel doesn't know about it.  To the OS kernel, it's only
one process.  It's the runtime library that implements handles user-level
threads. 
  And since the kernel doesn't know about user-level threads, a context
switch means all the user threads in the same process get swapped out (or
in).  Also for the same reason, user-level threads within the same process
cannot make use of multiple processors at once.

/Thuan



-------------------------------------------------------------------
Thuan Q. Pham
Hewlett-Packard Laboratories              (415) 857-6818
1501 Page Mill Road                       pham@hpl.hp.com
Palo Alto, Ca 94303



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-06-11  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-06-10  4:00 FAQ Request robj
1998-06-11  4:00 ` N Madden
  -- strict thread matches above, loose matches on Subject: below --
1993-10-12  2:39 Threads better than forks? Thuan Q. Pham
1993-10-14 15:23 ` FAQ request Steven Wayne Hudson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox