Using boost::interprocess shared memory for both 32-bit and 64-bit processes
Hello, I would like to read/write from/to boost::interprocess shared memory segments from a 32-bit process and a 64-bit process on the same machine. Is this possible? I've attempted to do this, but I seem to be experiencing some compatibility issues. Note that I am reading/writing boost::inteprocess containers to shared memory. For example, in my 32-bit process, I'll add some data to a boost::interprocess::vector and when I read this data from my 64-bit process, it returns garbage. Are there compiler options I can set to make things compatible? If it is not possible to do this, what are some possible solutions for this? Thanks, J
El 20/09/2010 16:32, Jonathon escribió:
Hello,
I would like to read/write from/to boost::interprocess shared memory segments from a 32-bit process and a 64-bit process on the same machine. Is this possible? I've attempted to do this, but I seem to be experiencing some compatibility issues. Note that I am reading/writing boost::inteprocess containers to shared memory.
No. Basic data types used inside interprocess have no fixed width, so processes with different ABIs can't shared managed resources. Note that if the compiler uses a different ABI (EBO optimization, etc..) for 64 and 32 processes you an additional problem.
If it is not possible to do this, what are some possible solutions for this?
There is fix, unless you reimplement Interprocess using news fixed width classes :-( Best, Ion
On Mon, Sep 20, 2010 at 10:32 AM, Jonathon
I would like to read/write from/to boost::interprocess shared memory segments from a 32-bit process and a 64-bit process on the same machine. Is this possible? I've attempted to do this, but I seem to be experiencing some compatibility issues. Note that I am reading/writing boost::interprocess containers to shared memory.
For example, in my 32-bit process, I'll add some data to a boost::interprocess::vector and when I read this data from my 64-bit process, it returns garbage. Are there compiler options I can set to make things compatible?
I think that to exchange data between different processor architectures, you can't avoid the need for some sort of data conversion. It's tempting to suggest using Boost.Serialization to format your data into a text archive represented in an interprocess string, then read it from the other process the same way. But if you're starting down that path, it strikes me that using an operating-system FIFO instead of shared memory would be simpler, possibly more robust, and probably about as fast.
participants (3)
-
Ion Gaztañaga
-
Jonathon
-
Nat Linden