Keywords: perfbook_html

#### 14.2.12.1.1 LOCK Followed by UNLOCK:

A LOCK followed by an UNLOCK may not be assumed to be full memory barrier because it is possible for an access preceding the LOCK to happen after the LOCK, and an access following the UNLOCK to happen before the UNLOCK, and the two accesses can themselves then cross. For example, the following:

      1 *A = a;
      2 LOCK
      3 UNLOCK
      4 *B = b;

might well execute in the following order:

      2 LOCK
      4 *B = b;
      1 *A = a;
      3 UNLOCK

Again, always remember that both LOCK and UNLOCK are permitted to let preceding operations ``bleed in'' to the critical section.

Quick Quiz 14.11: What sequence of LOCK-UNLOCK operations would act as a full memory barrier? End Quick Quiz

Quick Quiz 14.12: What (if any) CPUs have memory-barrier instructions from which these semi-permeable locking primitives might be constructed? End Quick Quiz