preemptive vs cooperative: attempt at formalization

John Meacham john at
Wed Apr 12 06:24:17 EDT 2006

On Wed, Apr 12, 2006 at 10:58:32AM +0100, Simon Marlow wrote:
> I don't know what it means for a thread to "have value _|_".  A thread
> is defined by its observable effects, threads don't have values.

sure they do, the value is just usually discarded. cooperative
implementations are just the ones that don't have that luxury. :)

> What if one of the threads never yields in a cooperative system?  Even
> if it isn't calculating _|_, if it's just endlessly doing some pointless
> IO?

All real IO would have to effectively be a potential yield point. This
is in practice assumed of any state threading implementation, but
perhaps we should make it part of the standard to be sure. by real IO I
mean reading/writing file descriptors and other interaction with the
real world and not just anything in the IO monad. I don't think we need
to do anything like enumerate the yield points or anything (except the
'yield' function of course), meeting the progress guarentee ensures a
liberal sprinkling of them throughout the standard libs, in particular
on any file descriptor read or write.

Of course, if the user really wanted to, they could "cheat" using
something like mmaping a file into memory and writing to that in a tight
loop, but hopefully any user doing something like that would be aware of
the ramifications. (heck, it would probably lock up the old version of
ghc too if the tight loop thread never needed to GC)


John Meacham - ⑆⑆john⑈

More information about the Haskell-prime mailing list