3 ms·
I guess you're assuming the compiler will issue an "increment" instruction for the ++, and that instruction is atomic. It's not a great coding practice. Move t
by kabdib 11y ago
I guess you're assuming the compiler will issue an "increment" instruction for the ++, and that instruction is atomic.
It's not a great coding practice. Move to a different processor (this happens!) and your code turns into a load-add-store, gets interrupted halfway through, and you scratch your head for a while about the mysterious and flaky FIFO failures.
Been there. At least a gesture towards an atomic operation would be nice, when you have data shared between interrupt and non-interrupt code.
- onnoonno 11y agoHow about putting #if !defined(__AVR__) && !defined(__MSP430__) #warning "Fix this FIFO - ++/-- possibly not atomic!" #endif into the header of that thingy then. Save work on small uCs, and be warned when moving it somewhere else.