ygramoel
ygramoel
DIIDevHeads IoT Integration Server
Created by Marvee Amasi on 4/25/2024 in #middleware-and-os
please I have a question
These functions are equivalent. The compiler is allowed to optimize them as if your code is single threaded. In both cases, it is allowed to read once or multiple times. In a multicore environment, it can read from a local cache. There is no guarantee in either case that ga will only be read once. Also no guarantee that the value used will be the last value written to ga. The only (simple) way to make this code work predictably in a multi-threaded context is to use a mutex, and lock it before accessing ga
16 replies