Marvee Amasi
Marvee Amasi
DIIDevHeads IoT Integration Server
Created by Sterling on 7/4/2024 in #middleware-and-os
Handling Non-Atomic Operations for 64-bit Variables on a 32-bit Non-Preemptive System
I know double buffering is a common technique for handling non atomic operations. You can create two 32-bit variables buffer_a and buffer_b and use them as a double buffer. ISR would update one buffer say buffer_a with the new microsecond count. The read function would access the other buffer buffer_b . You can then toggle between which buffer the ISR writes to and which the read function accesses so that a complete value is always read, even if ISR updates the other buffer during the read operation
8 replies