4 ms·
Are you talking about just mapping a file into memory? Because there are only two function calls you need to do something like that in POSIX: open(), and then
by jschwartzi 10y ago
Are you talking about just mapping a file into memory? Because there are only two function calls you need to do something like that in POSIX:
open(), and then mmap().
If you're talking about POSIX shared memory, you can do that with shm_open(). The only thing you have to do is have both processes use the same name for the shared memory area. Additionally, you can use POSIX named semaphores as a synchronization primitive.
It's pretty easy to wrap these functions up in a C++ class. You could conceivably share an entire C++ class between two processes using these primitives.
- faragon 10y ago"You could conceivably share an entire C++ class between two processes using these primitives." Not really. May be just memory mapping a plain class/struct, without virtual function tables, etc. (pointers are not necessarily valid from process to process)