127k views
2 votes
Assuming a single-processor system, that load and store are atomic, that x is initialized to 0, and that x must be loaded into a register before being incremented (and stored back to memory afterwards), what are all the possible values for x after both threads have completed

User Pwilcox
by
7.0k points

1 Answer

9 votes

Thread 2 read

Thread 1 read/write 4 times

Thread 2 write

Thread 1 read

Thread 2 read/write 4 times...

User Omz
by
7.1k points