Chandra
Chandra

Reputation: 309

To implement a Shared memory manager in C++

I have implemented a simple shared memeory code which is scattered in the two processes(1 acts writer and other acts as reader). But I want manage this SHM code(just like a memory manager),which works independent of any reader/writer processes. By simply giving some hooks/pointers to out side, Can any one suggests me a way for this. or any related code or links regarding related information to this ? One more this Can I use Zygote process to make it happen please suggest ?

Upvotes: 2

Views: 1703

Answers (2)

Jan Hudec
Jan Hudec

Reputation: 76316

Have a look at what Boost.Iterprocess can do for you. Especially have a look at the Managed Memory Segments section.

Upvotes: 2

Yann Ramin
Yann Ramin

Reputation: 33197

An application cannot "share" its memory using plain pointers on a modern operating system. This is something which requires the assistance of the OS, and is highly dependent on the OS in question. For instance, on Linux the best bet would be to use SysV Shared Memory.

Make sure you understand the overhead of multiple process shared memory and ask yourself if just using threads would not suffice. In most cases, threads will suffice, or if not you should re-think your model to use a message passing/shared nothing model.

Upvotes: 5

Related Questions