← Quiz: Semaphores and Classic Problems: all 9 questions
Quiz: Semaphores and Classic Problems · Question 3 of 9
Two threads each run x = x + 1 once on shared x = 0, with no lock. Which final values are possible?
Two threads each run x = x + 1 once on shared x = 0, with no lock. Which final values are possible?
- A.Only 2
- B.0, 1 or 2
- C.1 or 2
- D.Only 1
Answer & explanation
Correct answer: 1 or 2
If both load 0 before either stores, one update is lost and x is 1.
Can you get the rest right without peeking?
Take the timed Quiz: Semaphores and Classic Problems quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →