ygramoel
DIIDevHeads IoT Integration Server
•Created by Marvee Amasi on 4/25/2024 in #middleware-and-os
please I have a question
Thanks. For completeness, I'd like to add a note on 'volatile', as this directive is often misunderstood.
If the global variable ga is declared volatile, as in:
volatile int ga;
then the compiler will actually generate a read instruction (or read instructions) for each use of ga. So
func_a
wil have one read instruction, and func_b
wil have three. Also, each write to ga
will generate a write instruction (or instructions). However, no code will be emitted to sync any cache, so this is not a solution for a multithreaded program. volatile
is intended to be used (amongst others) for special function registers, where a read or write on the bus may actually trigger some hardware action in a peripheral.16 replies