What is a sample program that has an error caused by calling _ReadBarrier ()?

What is a sample program that has an error caused by calling _ReadBarrier ()?

MSDN article at _ReadBarrier (): http://msdn.microsoft.com/en-us/library/z055s48f(v=vs.120).aspx

+3


source to share


1 answer


This post, my favorite blogger, will explain everything you ever had about reading and writing barriers: Barrier (and in a very humorous and tongue in cheek, too)

The article is quite long and starts with the basics of synchronization (mutexes) and then goes deeper and deeper into various lighter weight synchronization methods and discusses barriers in detail. There are sample programs at every step along the way, including odd behavior (and the difficulty in getting this behavior to show up on modern machines because of the behavior of the processor).




BTW, (link to Hans comment). Not only Itaniums processors experience timing errors, Itaniums is designed to take full advantage of full reordering and parallelization, assuming the developer / compiler knows what he / she / he is doing and will use barriers wherever needed. Other platforms, such as x86, guarantee that certain instructions will be executed in order, while other platforms, such as x86_64, do not guarantee the orders of other instructions, but in practice and mostly for reasons of sanity and compatibility, they (usually) execute them in order ( see related blog post).

+1


source







All Articles