Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
From: rsalz@osf.org (Rich Salz)
Subject: Re: Threads better than forks?
Date: 12 Oct 1993 19:19:36 GMT	[thread overview]
Message-ID: <29f008$2fh@paperboy.osf.org> (raw)
In-Reply-To: 1993Oct11.170510.13690@mnemosyne.cs.du.edu

In <1993Oct11.170510.13690@mnemosyne.cs.du.edu> tgeorges@nyx.cs.du.edu (Thomas Georges) writes:
> "What's the advantage of using threads over fork/exec with signals?"

There is really only one true difference:  all threads within a process
share that process's state (e.g., global variables, open files, etc).  The
other differences, e.g., "forks are more expensive" and "scheduling is
different" are not architectural differences.  These, and other differences
mentioned on the net, vary among operating systems, and hardware.

Okay, given global shared state what can you do with it?  Here's a simple
use.  A client knows that there are 10 servers out there that can solve
its problem.  It spawns ten threads, each one doing an RPC.  The first
one that comes back sends a cancel message to the other nine.  Suppose you
want to keep 10 "calculators" busy each doing a partitioned part of, say,
a Mandelbrot calculation.  Each thread just pulls another chunk of the
problem out of a pool.  (Call it tuple-space and you just invented inverted
Linda. :-)

Correctly programming with threads is difficult.  There's a book on Modula-3
that has a great chapter on how to use threads; it was written by Andrew
Birrell and is a slight revision of a wonderful DEC technical paper.  The
book is worth it for just this chapter.
	/r$


      parent reply	other threads:[~1993-10-12 19:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-10-11 17:05 Threads better than forks? Thomas Georges
1993-10-11 18:25 ` Jon Mauney
1993-10-12  2:39   ` Thuan Q. Pham
1993-10-12 15:38     ` Lee Sailer
1993-10-12 18:04       ` zac
1993-10-12 18:53       ` Simon Patience
1993-10-14 15:37       ` Jari Tavi
1993-10-14 15:22     ` Steven Wayne Hudson
1993-10-14 18:57       ` Joshua Goldman
1993-10-15 17:39       ` Chris Fulmer
1993-10-14 15:23     ` FAQ request Steven Wayne Hudson
1993-10-13  9:11   ` Threads better than forks? Stuart John Cochran
1993-10-13 12:31     ` Simon Patience
1993-10-11 20:05 ` Brad Daniels
1993-10-12 19:19 ` Rich Salz [this message]
read-only archive

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