volatile vs memory barrier for interrupts
问题 Let x and y be variables that are shared between main code and interrupt code. My idea of volatile is that it is only and always needed for hardware variables and interrupt variables that are also used in main code. Every usage of x and y in the main code is guaranteed to be atomic by disabling interrupts. Do x and y really need to be volatile , or is it enough to put a memory barrier before using them to force reloading the variables from RAM? A) volatile bool x; volatile int y[100]; int