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