Make global float atomic?
Posted: Thu Jan 18, 2024 11:21 pm
Hi,
Multitasking is new to me, as is the ESP32 and ESP IDF framework.
I'm using a float variable, to share a value between tasks. Were it a 32-bit variable, I believe it's writes would be atomic. As a float value, however, I'm concerned that the reading task may acquiring the value, right in the middle of a non atomic series of write operations in the writing task, and hence read erroneous data.
Global floats probably aren't the best way to share values between tasks, but in a pinch, what's the most efficient means to enforce atomicity when the writing task adds new data? Critical section?
G.
Multitasking is new to me, as is the ESP32 and ESP IDF framework.
I'm using a float variable, to share a value between tasks. Were it a 32-bit variable, I believe it's writes would be atomic. As a float value, however, I'm concerned that the reading task may acquiring the value, right in the middle of a non atomic series of write operations in the writing task, and hence read erroneous data.
Global floats probably aren't the best way to share values between tasks, but in a pinch, what's the most efficient means to enforce atomicity when the writing task adds new data? Critical section?
G.