caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Dan Grossman <djg@cs.washington.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] STM support in OCaml
Date: Thu, 09 Mar 2006 09:10:19 +1100	[thread overview]
Message-ID: <1141855819.23909.66.camel@budgie.wigram> (raw)
In-Reply-To: <440F2ED8.8040108@cs.washington.edu>

On Wed, 2006-03-08 at 11:22 -0800, Dan Grossman wrote:

> As for "why concurrency if not to run faster", there _are_ other reasons 
> for certain applications:
>   * Multiple threads are a natural match for computations that are 
> naturally decomposed into multiple control contexts.

Yes, but one only uses *pre-emptive* threads here if the language
fails to provide control inversion/synchronous threads.
With synchronous threads you have interleaving, but no
concurrency. Felix, MLton, and Haskell provide synchronous
threads. 

Pre-emptive threads are less useful by comparison
due to their exceptionally poor performance on most OS,
limitations to their numbers, and the need for use of
interlocking primitives (mutex etc) which are generally
not required with synchronous threads. The latter not
only reduces performance, it also makes programming
very much more difficult. In particular, STM isn't as
useful with synchronous threads.

In fact most uses of 'multiple control contexts' call
for control inversion NOT pre-emption or concurrency:
what's required for the 'natural match' is to turn
the program 'inside out'.

Actually the idea extends to asynchronous control as well:
asynchronous callbacks, signals, or interruptions, can also
be interleaved and represented in control inverted form.
Felix is now doing both.

The effect is that as in C you would write 'read channel data'
or 'write channel data' in multiple threads. But actually
by control inverting this is turned into non-concurrent
callback/event driven code. There are indeed 'logical threads
of control' but no concurrency.

In Felix for example, we do use one thread for sockets
to synchronise the OS with the program: the end user, however,
can ignore this and write a web server supporting a million
active connections and not use a single bit of 'concurrency'.
[We could use pollling .. and indeed within the thread we
are: with epoll, kqueue, or io completion ports]

I do agree with what you're saying -- yes threads are a
natural fit for many problems. But 'concurrency' is generally
NOT what is required, and is in fact a serious obstacle to
both performance and ease of programming.

But it all depends on what you mean by 'concurrent'. The word
of course really does imply parallelism: con-current means
literally 'at the same time' which is generally impossible
on a uniprocessor (except perhaps for DMA, H/W accelerated
graphics, etc .. but then really you do have more than one
processor :)

Anyhow all this is just to say: lets not confuse the
need for Concurrency with the need for Control Inversion.

-- 
John Skaller <skaller at users dot sourceforge dot net>
Async PL, Realtime software consultants
Checkout Felix: http://felix.sourceforge.net


  reply	other threads:[~2006-03-08 21:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-08 10:11 yoann padioleau
2006-03-08 10:41 ` Asfand Yar Qazi
2006-03-08 12:23   ` skaller
2006-03-08 23:02     ` Asfand Yar Qazi
2006-03-09  0:36       ` skaller
2006-03-08 11:32 ` Gerd Stolpmann
2006-03-08 12:04   ` skaller
2006-03-08 19:22     ` Dan Grossman
2006-03-08 22:10       ` skaller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-03-07 16:18 Asfand Yar Qazi
2006-03-07 16:50 ` [Caml-list] " Sebastian Egner
2006-03-07 17:44   ` Michael Hicks
2006-03-08  0:37     ` Asfand Yar Qazi
2006-03-08  5:05       ` Erick Tryzelaar
2006-03-07 17:15 ` skaller
2006-03-07 19:05   ` Asfand Yar Qazi
2006-03-08  0:52     ` skaller
2006-03-08 10:38       ` Asfand Yar Qazi
2006-03-08 19:36       ` William Lovas
2006-03-08 20:45         ` Brian Hurt
2006-03-08 21:14           ` Paul Snively
2006-03-08 22:06           ` skaller
2006-03-08 22:10             ` Gerd Stolpmann
2006-03-08 23:48               ` skaller
2006-03-09  7:45               ` Andrae Muys
2006-03-09  9:18                 ` David Brown
2006-03-08 22:11             ` Brian Hurt
2006-03-08 23:05               ` Lodewijk Vöge
2006-03-09  3:13                 ` Brian Hurt
2006-03-08 23:45               ` Robert Roessler
2006-03-09  0:23               ` skaller
2006-03-09  3:19                 ` Brian Hurt
2006-03-09  4:32                   ` skaller
2006-03-09 10:38                     ` John Chu
2006-03-11 15:26             ` Florian Weimer

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=1141855819.23909.66.camel@budgie.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=djg@cs.washington.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).