does scheduling a callback preclude disabling interrupts?
does scheduling a callback preclude disabling interrupts?
I am using the <schedule> method to make an interrupt append an "event number" to a list. Works fine, no problem. My question is when I later on in the top-level code pop an event number off this "stack" do I need to globally disable/re-enable interrupts while I do this? I am suspecting that I don't have to. Is that correct?
Re: does scheduling a callback preclude disabling interrupts?
I think we'd need more information about the rest of your program. i.e. is your stack a high-level thing that can handle being pushed while it's in the middle of being popped?
schedule will cause the scheduled code to be executed synchronously between two VM instructions at some point in the future.
So it's not so much the interrupt handler that needs to be disabled but that your scheduled push code might be happening right in the middle of a pop. Disabling interrupts might not help because the scheduler can still run a previously scheduled event.
Instead you might want to do something like have a flag to "protect" the stack. If the push function (called by the scheduler) sees this flag set, then it can re-schedule itself. The pop function can set this flag while it's doing the pop.
schedule will cause the scheduled code to be executed synchronously between two VM instructions at some point in the future.
So it's not so much the interrupt handler that needs to be disabled but that your scheduled push code might be happening right in the middle of a pop. Disabling interrupts might not help because the scheduler can still run a previously scheduled event.
Instead you might want to do something like have a flag to "protect" the stack. If the push function (called by the scheduler) sees this flag set, then it can re-schedule itself. The pop function can set this flag while it's doing the pop.
Re: does scheduling a callback preclude disabling interrupts?
Thanks, I'll use your flag suggestion.