|
|
|
|
|
|
|
|
|
|
|
|
|
|
ä |
3
variables: A, B, C which are shared by
|
|
|
|
thread
T1 and thread T2
|
|
|
ä |
T1
computes C = A+B
|
|
|
ä |
T2
transfers amount X from A to B
|
|
|
|
ä |
T2
must do: A = A-X and B = B+X (so that
|
|
|
A+B
is unchanged)
|
|
|
ä |
But
if T1 computes A+B after T2 has done
|
|
|
A =
A-X but before B = B+X, T1 will not
|
|
|
|
obtain
the correct result for C = A + B
|
|
|
ä |
Solution:
critical sections (later)
|
|