...
NOTE 1 Two threads of execution can update and access separate memory locations without interfering with each other.
It is possible almost certain that flag1
and flag2
are stored in the same word. Using a compiler that conforms to C99 or earlier, if both assignments occur on a thread-scheduling interleaving that ends with both stores occurring after one another, it is possible that only one of the flags will be set as intended, and the other flag will contain its previous value, because both members are represented by the same word, which is the smallest unit the processor can work on. Before the changes made to the C Standard for C11, there were no guarantees that these flags could be modified concurrently.
...