c++ - Using Interlocks for thread synchronization and maintaining cache coherency -


if use kind of algorithm uses interlockcompareexchange operations on variable in c++ determines if set of data being written particular thread (by creating own little lock), how ensure interlocked operation updated value seen other thread if data being stored in say, level 2 cache on i7.

i know cache coherency used keep data across caches of multi-core processors consistent, small frame of time when 1 core updates variable interlock function , cache checks , fixes coherency problems while core checking variable has in own cache? problem fixed if ensured variable having interlockcompareexchange operation volatile changes written directly memory? correct believe memory barrier (memorybarrier() on vs) not ensure cache coherency ensures unwanted instruction reordering?

i hope question isn't vague. try answer comments if was. don't have source code post question don't have specific problems, know future reference if there problems this, c++0x having interlocks part of standard library.

thank you.

the compiler can't reorder loads or stores across interlocked function call, , implementation include whatever machine instructions needed make sure cpu core won't.

cache coherency maintained, thing have worry when value gets written out instruction pipeline cache, , that's ordering issue.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -