Skip to main content
gamedev.net
🔒 Locked

Shared memory

Started by Ki11Roy Jan 9, 2008 at 7:12 AM 1 replies 650+ views
Original Post
Ki11Roy
Ki11Roy
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!
Adam_42
Adam_42
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.
Ki11Roy
Ki11Roy
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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.