• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Shared memory

I want to have a region that can be read by many applications at the same time, but only one application at the time can write.  There can be no read during a write.  There can be many read at once.
Maybe with mutex or semaphore components...

Thanks in advance.
0
pchaloux
Asked:
pchaloux
  • 3
  • 2
1 Solution
 
jhurstCommented:
I am assuiming that you are using a REAL operating system.  Therefore, use a file, the OS will buffer it well enough that it will not seem like memory.
0
 
alexoCommented:
If you'd like a more helpful answer, consider this:

The OS [Assuming a Win32 platform] has support for everything you mention.

Shared memory between applications can be implemented via memory-mapped files.  The APIs you need are CreateFileMapping() and MapViewOfFile().

You will also need two locks - a read lock and a write lock (so you can have multiple readers but only one writer).  You can use semaphores for that.  The APIs you need are CreateSemaphore(), OpenSemaphore(), WaitForSingleObject() and WaitForMultipleObjects().

Note that in order to be used between processes, all your objects will need to be "named".
0
 
alexoCommented:
Hey, pchaloux, you there???
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pchalouxAuthor Commented:
I'm not using Win32.  I'm on MQX, witch is similar to QNX, but on a Motorola platform.

0
 
pchalouxAuthor Commented:
I'm not using Win32.  I'm on MQX, witch is similar to QNX, but on a Motorola platform.

0
 
alexoCommented:
Ask in the Unix area.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now