Quote:
surely you can do it with a circular buffer in software
Surely it could be done that way. I was going cross-eyed trying to code linked list and other OS operations in 6502/65816 assembler. Given the instruction set, I thought it would be easier to implement with hardware. It's much shorter code and faster too to use hardware support.
Quote:
But one thing that is difficult to reliably do in SW is to easily make this operation atomic.
Yes, it's not so easy as just setting the interrupt mask sometimes. Throw multiple cpu's into the mix then semaphore's need to be used. And getting atomic bus operations may not be simple, the hardware has to support it. I added support for atomic operations to the system memory controller, but that made it more complex.
I had a problem using the interrupt mask because enabling interrupts incurred a three instruction delay. This caused interrupts to be enabled for the wrong task sometimes depending on when a task switch occurred. The following code didn't work:
Code:
PLP ; clears interrupt mask by restoring it
RTT ; switches back to original task
Quote:
the Inmos transputer did most of these things in non-interruptable microcode, which seamlessly provides the atomic OS-related functionality that is missing from many modern instruction sets.
I noticed that large sections of code are run with interrupts disabled anyways, so a micro-coded approach seems like a reasonable alternative to getting things done quickly.
I've gone ahead and added a hardware supported timeout list as well. The timeout list component manages the timeouts using a linked list internal to the component. It has to walk a linked list and can do so while running asynchronously to the processor.