Solved

Shared memory

Posted on 1998-06-03
6
178 Views
Last Modified: 2010-04-15
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
Comment
Question by:pchaloux
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
jhurst earned 200 total points
ID: 1251103
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
 
LVL 11

Expert Comment

by:alexo
ID: 1251104
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
 
LVL 11

Expert Comment

by:alexo
ID: 1251105
Hey, pchaloux, you there???
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:pchaloux
ID: 1251106
I'm not using Win32.  I'm on MQX, witch is similar to QNX, but on a Motorola platform.

0
 

Author Comment

by:pchaloux
ID: 1251107
I'm not using Win32.  I'm on MQX, witch is similar to QNX, but on a Motorola platform.

0
 
LVL 11

Expert Comment

by:alexo
ID: 1251108
Ask in the Unix area.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now