3 ms·
No, the author can use all entries in the buffer. The space cost is hidden in that one of the pointers need to hold X+1 values, ie for 256 entries it is not eno
by mungoman2 11y ago
No, the author can use all entries in the buffer. The space cost is hidden in that one of the pointers need to hold X+1 values, ie for 256 entries it is not enough with 8-bit indices.
An unfortunate effect of this implementation is that both indices are modified by the consumer. It's not safe to write/read dats from different contexts, something that would be very useful in a driver.
- rhaps0dy 11y agoAh, thanks for explaining. Now it makes sense.
- codehero 11y agoYeah your intuition is correct here. On an MSP430 (which is were I use it) the producer is in interrupt context but as a savvy redditor pointed out, I will need to enable/disable interrupts in the consumer function as well.