Shared memory

Started by
1 comment, last by Ki11Roy 16 years, 3 months ago
Hello, I have two or more processes on the same computer and I need to share some data between them. Data is a table of users (~2000000 records ~100 bytes per record). Target operating system is Windows or Unix. (C++) What is the best way to synchronize those processes? Which way to go? Thanks in advance!
Advertisement
Named Pipesare one common solution on Windows. I believe there's a Unix equivalent too.

There's also various other options:

- Shared memory
- RPC (Remote Procedure Call)
- Use a database
- etc.

The best option will depend on the type and frequency of access to the data and performance requirements. Read only access for example makes shared memory much simpler - you could simply memory map the data file in both programs for example.

Shared memory will obviously get problematic if you end up with more than a GB or two of data on a 32-bit system, but you're well under that at the moment.
I think it will be read-only access, so I'll try to use shared memory. And after some digging, I found that for memory mapping on Linux exists
1) mmap function
2) shmget function
Many thanks to Adam_42!

This topic is closed to new replies.

Advertisement