Add a MOOC mutex for serializing internals
Early MOOC authors used
taskUnlock as quick-n-dirty ways to provide serialization. These primitives add latency to interrupts and context switches, respectively. It's inappropriate affecting other tasks and interrupts because someone was too lazy to properly serialize the data structures. To close this issue, we need:
- A global MOOC mutex to provide atomic changes to MOOC internals.
taskUnlockinstances should be converted to
- Bonus points for finding and fixing other areas that weren't properly protected1.
It should be noted that MOOC drivers can have a mutex associated with their instance, so care must be taken to ensure there's no possibility of deadlock in using these mutexes.
1 For instance, the multiple RETDAT tasks transfer packets to the RETDAT reply task and there's some slop in there because we couldn't guarantee things were happening atomically. This can now be fixed.