BigDumbDinosaur wrote:
Quote:
There's no need to save the program counter, since it's always pointing to the same place in the context switch routine.
Not true if a jiffy IRQ triggers the context switch, as would be the case with a truly preemptive scheme. There's no telling where PC will be pointing when the IRQ hits. Of course, servicing the IRQ automatically takes care of PC, as well as SR.
That's my point. The interrupt handler already takes care of saving PC, SR, A, X and Y. There's no need to do it again in the context switch routine.
Quote:
jonb said he wanted preemptive operation, hence the outline I gave him.
True, but preemptive multitasking is much more complex, and if you're not careful, can even result in worse performance. I find a lot of people wanting preemptive multitasking, just because it's "standard", and not because it's actually a better solution to the given problem. When dealing with customers in my business, I always try to solve their problems, and not their solutions.
Quote:
If the in-context process gets stuck in a loop the whole system screeches to a halt.
I'd fix the bad code, rather than designing a complex system around it to deal with it. Of course, this may not be an option for 3rd party code, but hey, realistically speaking, what's the chance that somebody will be running bad 3rd party code on a Micro UK 101 ?