
9.1 Relaxed Memory Consistency Models 691
Pi,
P
2
Pn
Lock(TaskQ)
newTask—»next = Head;
if (Head != NULL)
Head-»prev = newTask;
Head = newTask;
UnLock(TaskQ)
(a)
n
TOP:
while(flag2==0);
A = 1;
u = B
v = C
D = B * C
flag2 = 0
flagl = 1
goto TOP;
TOP:
while(flagl==0:
x = A;
Y = D;
B = 3;
C = D / B;
flagl = 0.
flag2 = 1,
goto TOP;
(b)
FIGURE 9.5 Use of synchronization operations to coordinate access to ordinary shared data
variables. The synchronization may be through the use of explicit lock, unlock, and barrier operations
or through the use of flag variables for point-to-point events.
i Read/write
Read/write
Sync
*
1 Read/write
1 Read/write ...