Why memory reordering is not a problem on single core/processor machines?
Consider the following example taken from Wikipedia, slightly adapted, where the steps of the program correspond to individual processor instructions: x = 0; f = 0; Thread #1: while (f == 0); print x; Thread #2: x = 42; f = 1; I'm aware that the print statement might print different values (42 or 0) when the threads are running on two different physical cores/processors due to the out-of-order execution. However I don't understand why this is not a problem on a single core machine, with those two threads running on the same core (through preemption). According to Wikipedia: When a program runs
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.