Memory reordering on a single core

Most memory order information refers to multicore / multicpu. I recently asked a question related to reordering, and the answer was mainly related to multi-core. After a little test on one main processor:

thread1()
{
 x++;
 y++;
}

thread2()
{
 if (x < y) 
   .... should not happen, because x is incremented first.
}

y happens more often on a multi-core weak ordered processor, but it still happens on a single processor core. (what I expected, but not mentioned in most articles)

Any impressions, confirmation or explanation of why this should not happen on any core (although it seems to be happening without any compiler optimization)?

+4
source share

All Articles