Subj : Re: Memory Barriers, Compiler Optimizations, etc. To : comp.programming.threads From : SenderX Date : Thu Feb 03 2005 05:10 pm >> 1. static T *shared = 0; >> >> >> 2. T *local = ac_cpu_i686_mb_load_ddhlb( &shared ); >> 3. if ( ! local ) >> 4. { ac_mutex_lock( &static_mutex ); >> 5. if ( ! ( local = shared ) ) >> 6. { local = ac_cpu_i686_mb_store_ssb( &shared, new T ); } >> 7. ac_mutex_unlock( &static_mutex ); >> } > If > the former, how are programmers in languages like C/C++ expected to make > the association between reads/writes and memory barriers? Just to clarify and answer your question directly: loads are usually associated with "consumer side" memory barriers. hoist-load-xxx, acquire, ect... stores are usually associated with "producer side" memory barriers. sink-store-xxx, release, ect... .