question about concurrency implementation

Simon Peyton-Jones simonpj@microsoft.com
Tue, 19 Mar 2002 04:03:40 -0800


Dean

| From Simon Marlow's reply, I gather that the current=20
| implementations of Concurrent Haskell provide "concurrency"=20
| but not "parallelism", and that provision of parallelism is=20
| not likely in the near term.

That's more or less right.  The trouble is that for shared-memory
parallelism

- you take a performance hit for fine-grain locking
- so you need real parallelism to recover that performance

All the pieces are there in GHC, mostly implemented; but making
it all really work, really reliably, and somewhat portably, is a
non-trivial task... and the reward (as I say above) can be elusive.

| I've asked these questions in order to convince myself that=20
| multiple threads can (and will) cooperate in lazily=20
| evaluating a value they share, without need for any special=20
| programming.  In particular, I plan to have multiple threads=20
| share values whose computations involve uses of=20
| `unsafePerformIO` (the safety of which my application's usage=20
| pattern guarantees).

Do make sure you understand Concurrent Haskell (I'm sure you do),
which is specifically about multiple threads each of which can perform
I/O.  (See "Tackling the awkward squad" on my home page.)   You are
on thin ice with unsafePerformIO, especially when concurrency is
involved.

Simon