Shared memory remote proxy in C ++
Suppose I have a daemon that divides its internal state into different applications via shared memory. Processes can send messages to IPC daemons over a named pipe to perform various operations. In this scenario, I would like to create a C ++ wrapper class for clients that acts as a kind of "Remote Proxy" to hide some gory details (sync, messaging, etc.) from clients and make it easier to highlight code for unit tests ...
I have three questions:
- Is this generally a good idea / approach?
- Do you have any hints or fixes for synchronization in this setting, or is it enough to use the default read / write mutex setting?
- Are there any frameworks I should consider?
The target in question is an embedded Linux system with 2.18 kernel, so there are limits on memory and compiler functionality.
a source to share
Herb Sutter had an article Sharing Is Root of All Contention in which I generally agree with; if you are using a shared memory architecture you are exposing yourself to quite a few potential threading problems.
The client / server model can make things much easier when clients write to a named server pipe and the server writes back to a unique client pipe (or uses sockets). It would also make unit testing easier (since you don't have to worry about testing shared memory), a mutex could be avoided, etc.
a source to share
There's a Boost.Interprocess library there , although I can't comment on its suitability for embedded systems.
a source to share