>>>> "Huw" == Huw Davies
<huw.davies at kerberos.davies.net.au> writes:
Huw> On 18/03/2005, at 7:04 AM, Paul Koning wrote:
> Come to think of it, cooperative multitasking is
trivial, you can
> code your own. It looks like this:
>
> for {;;} { task1(); task2(); task3; /* etc */ }
>
> and each task simply does stuff for a while, then returns when it
> has nothing left to do or when it's time to give another task a
> shot at the CPU. That sort of system is very simple and very
> reliable.
Huw> Anyone who's used a Macintosh before OS-X might want to disagree
Huw> here.
Depends on what you're doing.
If you want to run large workstation applications, then you want a
real Unix-style OS.
The original question was for a very small multitasking system, which
to me sounded more like an embedded/RTOS type of application. That's
where the cooperative style often works better.
One benefit of cooperative, rather than preemptive, scheduling is that
the scheduling properties and liveness properties of the various tasks
are very obvious. If reliability demands that everything gets a slice
of time, then cooperative multitasking, without priority, is a great
way to get the job done.
Yes, sometimes priorities are needed. But all too often, priorities
are used to hide the fact that the builder didn't analyze the job
sufficiently, and simply hacked the priorities until things seemed to
work in test.
paul