Subj : Re: Memory Barriers, Compiler Optimizations, etc. To : comp.programming.threads From : SenderX Date : Thu Feb 03 2005 06:28 pm >> loads: the consumer-side barrier is usually executed "AFTER" the load. >> >> movl %(eax), %ecx >> ; consumer-side barrier > >> stores: the producer-side barrier is usually executed "BEFORE" the store. >> >> ; consumer-side barrier ^^^^^^^^^^^^^^^^^^ Thats suppose to be producer-side. >> movl %ecx, %(eax) > > Are you sure that it's not the opposite? Yes, I'm sure. Here is why: /* example of correct code */ /* processor A - executes producer-barrier "before" the store to shared */ object_t *local = create_object( . ); ac_cpu_mb_producer(); shared = local; /* processor B - executes consumer-barrier "after" the load from shared */ object_t *local = shared; ac_cpu_mb_consumer_dep(); if ( local ) { use_object( local ); } If you reverse that logic, you break the hell of it: /* example of busted code */ /* processor A */ object_t *local = create_object( . ); shared = local; ac_cpu_mb_producer(); /* no, no */ /* processor B */ ac_cpu_mb_consumer_dep(); /* no, no */ object_t *local = shared; if ( local ) { use_object( local ); } Understand now? ;) .