Is atomicity guaranteed on data residing in shared memory?

 

E.g. Processes allocate shared memory as follows using either create_only and truncate or open_only:

 

#define SHARED_MEM_SIZE sizeof(boost::uint32_t)

#define SHARED_MEM_NAME "SHMTest"

 

boost::shared_ptr<shared_memory_object> shm_obj;

boost::shared_ptr<mapped_region> mapping;

std::string sharedMemoryName(SHARED_MEM_NAME);

 

shm_obj.reset(new shared_memory_object(create_only, sharedMemoryName.c_str(), read_write));

 

shm_obj->truncate(SHARED_MEM_SIZE);

 

mapping.reset(new mapped_region(*shm_obj, read_write, 0, SHARED_MEM_SIZE));

 

Then, they use the boost atomic functions to read and write to the memory:

 

volatile boost::uint32_t* temp = static_cast<volatile boost::uint32_t*>(mapping->get_address());

 

unsigned int value = boost::interprocess::detail::atomic_read32(temp);

 

boost::interprocess::detail::atomic_write32(temp, value);

 

Are these memory accesses guaranteed to be atomic? Platform is Linux if that makes a difference.

 

Thanks

 

 

 

 

 

 

 

 

 


P
Please consider the environment before printing this email

This e-mail and any files transmitted with it are confidential, may be legally privileged, and are for the sole use of the intended recipient. Copyright in this e-mail and any accompanying document created by us is owned by us. If you are not the intended recipient of this e-mail or any part of it please telephone our IT Department at the number shown above or by e-mail at info@schneidertrading.com.

You should not use or disclose to any other person the contents of this e-mail or its attachments (if any), nor take copies. This e-mail is not a representation or warranty and is not intended nor should it be taken to create any legal relations, contractual or otherwise.

Schneider Trading Associates Ltd (Registration No. 3692131) is incorporated in England and Wales and the registered office is at 25 Copthall Avenue, London EC2R 7BP. The company is authorised and regulated by the Financial Services Authority