Enumerate atomic thread interleavings
Synchronization & Concurrency

Answer & solution
Official answer: A
Approach: Preserve each thread's internal order while allowing every merge of the two two-statement sequences.
1. Label T1's statements A: increment a, B: increment b; label T2's statements C: double b, D: double a. Legal interleavings satisfy A before B and C before D.
2. There are six such orders: ABCD gives (4,4); ACBD gives (4,3); ACDB gives (4,3); CABD gives (4,3); CADB gives (4,3); CDAB gives (3,3). For example, ABCD increments each initial 1 to 2 before doubling it to 4.
3. Removing duplicates leaves {(4,4),(4,3),(3,3)}.
4. To see why (3,4) is impossible, a=3 would require D before A, while b=4 would require B before C. Together with the thread orders this demands C<D<A<B<C, an impossible cycle.
Answer: A. Atomic assignments prevent lost updates inside an assignment, but do not force a whole thread to run as one unit.
