CS FundamentalsHardGATE CS

Shared int x = 1. Thread T1 executes `x = x * 2;` and T2 executes `x = x + 3;` concurrently with no locking (each is load, compute, store). How many DISTINCT final values of x are possible?

  1. A. 4
  2. B. 2
  3. C. 3
  4. D. 1

Correct answer: A. 4

Serial orders give (1×2)+3 = 5 and (1+3)×2 = 8; lost updates give 2 (T2's store overwritten) or 4 (T1's store overwritten). Possible values: [2, 4, 5, 8].

More Operating Systems questions

Exams that ask this topic