preemptive vs cooperative: attempt at formalization

John Meacham john at repetae.net
Wed Apr 12 00:39:09 EDT 2006


On Tue, Apr 11, 2006 at 09:05:12PM -0700, oleg at pobox.com wrote:
> > [Rule 1]
> > * in a cooperative implementation of threading, any thread with value
> >   _|_ may cause the whole program to have value _|_. In a preemtive one,
> >   this is not true.
> 
> I'm afraid that claim may need qualifications:
> 
>  1. if there is only one runnable thread, if it loops in pure code,
> the whole program loops -- regardless of preemptive/cooperative
> scheduling.
> 
>  2. in a system with thread priorities, if the highest priority thread
> loops (in pure code or otherwise), the whole program loops -- again
> irrespective of the preemptive/cooperative scheduling.
> 
>  3. [a variation of 1 or 2]. A thread that loops in a critical section
> (or holding a mutex on which the other threads wait) loops the whole
> program -- again, irrespective of preemptive/cooperative scheduling.

would the simple qualifier
'if there exists another runnable thread'

solve the issues?

A thread is not runnable if it is waiting on a resource or can't run due
to the priority policy of the scheduler. and it means there is at least
one other thread to switch to.


perhaps we should just make the ability to implement 'merge' and
'nmerge' the difference. though, defining the behavior of those routines
very well could be a harder problem than defining the difference between
preemptive and cooperative in the first place.


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-prime mailing list