Tracing a lost update step by step

A shared integer x starts at 7. Threads A and B each execute x++, which the processor performs as three steps: load x into the thread's register, add 1 to the register, then store the register back to x. The scheduler runs the six steps in the order shown. Fill in each thread's register value and the value of x in memory after each step, as integers.

StepActionRegister of ARegister of Bx in memory
1A loads xnot loaded
2A adds 1not loaded
3B loads x
4A stores its register
5B adds 1
6B stores its register

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Parallel Programming Questions: