[interprocess] is mapped_region construction threadsafe?

Hi, For a given shared memory object, is construction and use of a mapped_region threadsafe? For example, is the following going to be threadsafe: namespace ipc = boost::interprocess; ipc::file_mapping fmap("file.bin", ipc::read_write); void threadfunc(unsigned idx) { ipc::mapped_region r(fmap, ipc::read_write, idx*1024, 1024); ... } for (unsigned i=0; i<10; ++i) start_thread(boost::bind(threadfunc,i)); --- or, in OpenMP-speak: --- ipc::file_mapping fmap("file.bin", ipc::read_write); int idx; #pragma omp parallel for private(idx) for (idx=0; idx<10; ++idx) { ipc::mapped_region r(fmap, ipc::read_write, idx*1024, 1024); ... } Thanks, -bryan

=?ISO-8859-1?Q?Ion_Gazta=F1aga?= writes:
Bryan Green wrote:
Hi,
For a given shared memory object, is construction and use of a mapped_regio n threadsafe?
It should have the same thread-safety as two concurrent mmaps, but I haven't tested it. Are you having problems?
I'm having a problem, but I don't know its source yet. The bug could be elsewhere in my OpenMP program, but this was an obvious first question to ask. I suspect you are right that it is thread-safe. If I find that its not, I'll be sure to let you know. Thanks, -bryan
participants (2)
-
Bryan Green
-
Ion Gaztañaga