Figure 9-1.
A diagram showing happens-before relationships in a situation with two threads.
Each thread is represented by a sequence of boxes, one per operation. Within each thread, each box has an arrow to the next.
The first thread has four operations:
3 and 4 together form a group labeled “unlock”.
The second thread starts with a group of four operations labeled “lock”:
There is an arrow from the release operation on the first thread to the fourth operation on the second thread. The value 0 is emphasized in both boxes, to show that the arrow was created because of the acquire operation observing the 0 that the release operation stored.
The second thread continues with “access protected data”, and a group of two operations labeled “unlock”: release-swap 2 to 0, and wake one.