A point of view of their own, there is not the right place please advise
1, A,b,c is a global variable, two threads run the following code in parallel, then A's finally result may be
Four statement permutations (each program's statement order cannot be reversed)
The result is 4,13,15,26
Note: There is no writeback problem, since a,b,c are global variables, two threads share these variables. And there is no self-operating operator in the program, so there is no writeback problem
2.
Answer a
Note: There is a write back problem here. Because of the existence of the self-operation operator. That is ++a, the compiler should handle this
temp=a+1;
A=temp;
And a=temp This sentence is write back operation. Temp is a temporary variable that exists in the stack space of each thread (that is, two threads are different temp). And this sentence is not deterministic with the order in which printf is run
Thinking of two multi-threaded written test questions