CS FundamentalsVery hardGATE CS

Shared x = 1. T1 does `x = x + 1;` T2 and T3 each do `x = x * 2;` (load, compute, store, no locks). How many distinct final values of x are possible, and what is the largest?

  1. A. 6 values; largest 8
  2. B. 6 values; largest 6
  3. C. 3 values; largest 8
  4. D. 8 values; largest 10

Correct answer: A. 6 values; largest 8

Serial orders give (1+1)×2×2 = 8, 1×2×2+1 = 5, and 1×2+1 then ×2 = 6; lost updates add smaller values. Enumerating all interleavings gives [2, 3, 4, 5, 6, 8], i.e. 6 values with maximum 8.

More Operating Systems questions

Exams that ask this topic