9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: [9fans] cooperative threads
Date: Fri, 18 Aug 2000 18:06:14 -0400	[thread overview]
Message-ID: <200008182206.SAA19560@cse.psu.edu> (raw)

A more important point is that coroutines,
or cooperative or non-preemptive threads,
or whatever you want to call them, have their
benefits.

As demonstrated by early versions of Windows
and the Macintosh OS, reliance on cooperative
threading alone is a recipe for disaster, since 
it requires that all threads be bug free.  Thus,
used as an OS's primary scheduling mechanism,
cooperative threading requires that all executing
programs be bug free, a very strong and very
unlikely condition.  In that arena, cooperative
threading is not the right framework.

In more controlled settings, cooperative 
threading can work well.  If you arrange things
so that the only accesses to a data structure
are from threads inside a single proc, you
don't need to lock the data structure as long
you don't do a potentally blocking operation
(like communication) while manipulating it.
This is just one small benefit.  Structuring 
using coroutines can simplify other aspects
as well.  See, for instance, the ``Concurrency
in the Implementation'' section of the Acme
paper, any of the three references listed in
that section, and www.cs.dartmouth.edu/~doug/squint.ps.gz.

One of my gripes about the software-writing
world is that too many people hear threads
and think of performance alone.  A friend of
mine was taking a networks class and was
barred from using threads to simplify his
program structure.  The justification given
was that on the OS in question the thread 
package did not involve the kernel, so there
were no performance wins to be gained.
Thus using threads had no point.

My intent is not to get into an argument over what
the ``right'' scheduling model is, since it depends
greatly on the task at hand.  Instead I simply
wish to point out that cooperative threads do
have their uses and merit a place as a single tool
in a larger toolbox.

Russ



             reply	other threads:[~2000-08-18 22:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-18 22:06 Russ Cox [this message]
2000-08-18 22:56 ` Boyd Roberts
2000-08-19  6:34 ` Lucio De Re
2000-08-21  8:59   ` Douglas A. Gwyn
2000-08-21 13:01 rob pike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200008182206.SAA19560@cse.psu.edu \
    --to=rsc@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).