3 ms·
Yes, I read your comment. :) What I was saying is that when you're using shared memory to talk to another thread or process (which by definition is running on
by Avernar 11y ago
Yes, I read your comment. :) What I was saying is that when you're using shared memory to talk to another thread or process (which by definition is running on another thread) you need to use memory barriers or the processor may do the same optimizations (and more) that your compiler did. On top of that other cores may not see your read/writes.
Debug mode tends to always work because it writes code as if everything was effectively volatile. After that it depends on how the threads/processes are scheduled on what core. Without proper synchronization it may work, may work slowly, may not work once in a blue moon or fail all the time. Current processor may run it fine and then it may stop working on future processors.
Fortunatly if you use things like mutexes then the barriers are handled for you.
Depends on the compiler if the barier intrinsics need volatile. I'll have to do some research on that.