preemptive vs cooperative: attempt at formalization
John Meacham
john at repetae.net
Wed Apr 12 16:34:28 EDT 2006
On Wed, Apr 12, 2006 at 05:50:40PM +0100, Malcolm Wallace wrote:
> The argument John was making is that this is a useful distinguishing
> point to tell whether your concurrent implementation is cooperative or
> preemptive. My argument is that, even if you can distinguish them in
> this way, it is not a useful distinction to make. Your program is
> simply wrong. If you have a sequential program whose value is _|_, your
> program is bad. If you execute it in parallel with other programs, that
> does not make it any less bad. One scheduler reveals the wrongness by
> hanging, another hides the wrongness by letting other things happen. So
> what? It would be perverse to say that the preemptive scheduler is
> semantically "better" in this situation.
Oh, I didn't mean it was necessarily a useful quality to the end
programmer, I was actually just trying to make the point you were making
that such programs are incorrect and getting the non-termination case
over with. So we can get to the fairness discussion without adding
caveats like "if no thread is in an infinite loop". But I didn't want to
just say "assuming your program is correct" without giving some
indication of what that actually means for a program to be correct. In
any case, it is something we can point to and say "this! this is a
difference!" whether it is a useful one or not.
now for the contrived counter-example :)
start two threads, one trying to prove goldbachs conjecture, the other
trying to find a refutation. in a preemptive system this will terminate*,
in a cooperative system it may not.
John
* insert goedel incompleteness caveat.
--
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-prime
mailing list