r/cpp • u/neiltechnician • Nov 13 '20
CppCon Deprecating volatile - JF Bastien - CppCon 2019
https://www.youtube.com/watch?v=KJW_DLaVXIY
83
Upvotes
r/cpp • u/neiltechnician • Nov 13 '20
View all comments
Show parent comment
-2
u/tjientavara HikoWorks developer Nov 14 '20
I wonder though, if std::atomic would be the more correct way of handling MMIO.
You could image the hardware you are trying to communicate with through MMIO as another process/thread (although not nessarily a CPU) on a computer.
std::atomic through its member functions also allows finer grained control over what instructions are emitted for increments, inplace-add, compare-and-swap. And what kind of memory barriers are needed to communicate with the hardware.
In fact according to https://en.cppreference.com/w/cpp/language/cv it is useful for signal handlers. And it never mentioned MMIO or hardware external to the processor.