Good afternoon,
I'm currently trying to figure out a way to transfer data between a 64-bit process and a 32-bit process. Since this is a real-time application, and both work on the same computer, I use shared memory (shm) hard.
While I was looking for some kind of synchronization mechanism using shm, I felt in boost :: message_queue. However, it does not work.
My code is basically the following:
Sender
message_queue::remove("message_queue"); message_queue mq(create_only, "message_queue", 100, sizeof(uint8_t)); for (uint8_t i = 0; i < 100; ++i) { mq.send(&i, sizeof(uint8_t), 0); }
Recipient
message_queue mq(open_only, "message_queue"); for (uint8_t i = 0; i < 100; ++i) { uint8_t v; size_t rsize; unsigned int rpriority; mq.receive(&v, sizeof(v), rsize, rpriority); std::cout << "v=" << (int) v << ", esize=" << sizeof(uint8_t) << ", rsize=" << rsize << ", rpriority=" << rpriority << std::endl; }
This code works fine if two processes are 64-bit or 32-bit. But it does not work if the two processes do not match.
Looking for deeper code (1.50.0), you will see the following line in message_queue_t :: do_receive (boost / interprocess / ipc / message_queue.hpp):
scoped_lock lock (p_hdr-> m_mutex);
For some reason, the mutex seems to be locked out when dealing with heterogeneous processes. My wild guess was that the mutex is biased, and so the meaning is distorted, but I'm not sure.
Am I trying to accomplish something that is simply not supported?
Any help or advice would be appreciated.