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