Pre-emptive or co-operative concurrency (was: Concurrency)

Malcolm Wallace Malcolm.Wallace at
Thu Mar 30 10:30:10 EST 2006

> > What does YHC do about in-progress thunk evaluations when a context
> > switch happens?  Does it use blackholing like GHC, or does it
> > portentially duplicate the work, or something else?
> As far as I am aware, since it only switches on instruction
> boundaries, it never has to worry about this.

Not quite true.  If the same shared expression occurs in two different
threads, the first thread to come across it may start evaluating it,
then be suspended before completing.  If the second thread then comes
along and tries to evaluate the expression, what should it do?  There
are two choices:

  * Restart evaluating the expression from the beginning.
    (Duplicates the work, updates the same closure twice.  Let's hope
    closure-update is atomic, or there could be race conditions.)
  * Back off and let the original thread complete the work.
    (Implies blackhole detection, plus a queue of threads blocked on
    blackholes rather than on MVars.)


More information about the Haskell-prime mailing list