Based on my understanding, if I have a global variable and two or more threads that are trying to access it, and each thread is running on a different CPU core, then each CPU core will cache a copy of the global variable and whenever a thread tries to access the global variable, it is the cached copy that will be accessed, and not the global variable in memory.
Now say that I have two threads created using CreateThread() and each thread is running on a different CPU core, and one thread sets a global variable's value while the other thread reads its value.
Is there an Assembly instruction that forces the cached copy of the global variable to be flushed to memory after setting its value, or an Assembly instruction that updates the cached copy of the other CPU core that the other thread is running on?