I've stumbled about this thread: Why is volatile not considered useful in multithreaded C or C++ programming?
and stumbled upon the following in the top voted answer...
However, memory barriers also ensure that all pending reads/writes are executed when the barrier is reached, so it effectively gives us everything we need by itself, making volatile unnecessary. We can just remove the volatile qualifier entirely.
Since C++11, atomic variables (std::atomic) give us all of the relevant guarantees.
I'm working on C++98 capable platform, so what memory barrier was available for C++98? I've tried to use mutex for mbed, but I can't logically determine if a mutex is a sufficient way to protect, for example, both a serial write and read happening in two simultaneous threads, since I don't have enough confidence in regards to thread-safety.
What is an easy way to access a simple shared resource in c++98?