Boost logo

Boost Users :

From: Bryan Green (bryan.d.green_at_[hidden])
Date: 2008-05-23 19:00:38


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net