Cache coherency primer (2014)
fgiesen.wordpress.com
fgiesen.wordpress.com
Seemingly innocent code like this will most likely cause completely unnecessary inter-core traffic (assuming that the compiler has laid out a and b adjacently, and they both fall within the boundaries of a single cache line):
unsigned a, b;
void thread_a(void) {
for (;;) a++;
}
void thread_b(void) {
for (;;) b++;
}