Shared memory is a popular topic currently,
Try boost::InterProcess - which provides mechanisms that could be used and utilizes common code x-platform.
http://www.boost.org/doc/libs/1_52_0/doc/html/interprocess/sharedmemorybetweenprocesses.html
The other reason is that the library provides mechanisms for synchronisation and other IPC mechanisms that may be useful in the future.
http://www.boost.org/doc/libs/1_52_0/doc/html/interprocess/synchronization_mechanisms.html
For reference the thing uses Atomic OPs as well for the mutex:
http://www.boost.org/doc/libs/1_52_0/boost/interprocess/sync/spin/mutex.hpp
inline void spin_mutex::lock(void)
{
do{
boost::uint32_t prev_s = ipcdetail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 1, 0);
if (m_s == 1 && prev_s == 0){
break;
}
// relinquish current timeslice
ipcdetail::thread_yield();
}while (true);
}
Also from the "chat below" this post look at the top answer for : Is there a difference between Boost's scoped mutex and WinAPi's critical section?