preemptive vs cooperative: attempt at formalization
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Wed Apr 12 06:40:58 EDT 2006
John Meacham <john at repetae.net> wrote:
> In a concurrent implementation, a thread performing an infinite loop
> with no IO or interaction with the outside world can potentially stall
> switching to another thread forever, in FP, we usually denote an
> infinite loop by _|_. so I think the first difference would be:
By infinite loop, you mean both non-terminating, and non-productive. A
non-terminating but productive pure computation (e.g. ones = 1:ones) is
not necessarily a problem. Why? Because ultimately the demand that
forces production of the infinite data structure must come from
somewhere, and that somewhere must essentially be I/O. (The only
alternative consumers are terminating pure (no problem), non-terminating
productive pure (so look upward to its demand), or an unproductive
non-terminating computation, which brings us full circle.)
It is a curious artifact that in certain multi-threaded implementations,
a non-terminating non-productive thread does not make the entire system
unproductive, but I don't think this is a behaviour anyone would want to
rely on. I would say such a program has a bug, and the threaded RTS is
just masking it.
Regards,
Malcolm
More information about the Haskell-prime
mailing list