Boost logo

Boost :

Subject: [boost] [atomic] Help understanding consume order
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-06-01 06:58:03


Hi,

I'm reviewing (again) Boost.Atomic code and struggling to understand the
consume order and in particular what should it mean on architectures other
than DEC Alpha.

I read the explanation here:

http://en.cppreference.com/w/cpp/atomic/memory_order

but the point eludes me. Take ARM for example and the explanation in the
"Release-Consume ordering" section. The producer thread allocates the string
and stores the pointer with a release operation, so that the pointer, the
string contents and the 'data' integer are visible to other threads.

Now the consumer thread reads the pointer with a consume operation. According
to the explanation in the article, on ARM the consume operation need not issue
any specific fences to be able to use the pointer and the string body. In that
case, the consume operation becomes equivalent to relaxed (plus prohibiting
compiler optimizations). But is there a guarantee that the string body will be
visible to the consumer? Shouldn't the consume operation be promoted to
acquire instead?

I guess, that's the ultimate question: how should consume ordering be handled
on conventional architectures?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk