473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Shared memory - how to implement in .NET 2.0/3.0

I am coding a dozen "background" realtime apps for factory automation in .NET
2.0.

The apps need to share a common memory as there are lots of variables to be
shared (and synchronized of course).
I need distinct apps for reasons like user interaction/access rights, error
compartments, and because the size of the code, access to various ports, ...

In the end the apps should run as Windows Service(s).

How can I implement shared memory using .NET 2.0/3.0?

thanks herbert
Nov 26 '06 #1
4 3092
Hello herbert,

hThe apps need to share a common memory as there are lots of variables
hto be shared (and synchronized of course).

Shared among who? How much your app is distributed?
For example you can use MMF http://groups.google.com/groups/sear...y+mapped+file&
but I'm not sure that is the right thing for u

hI need distinct apps for reasons like user interaction/access rights,
herror compartments, and because the size of the code, access to various
hports, ...

So, u need the set of control services? how shared memory will help u here?

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 26 '06 #2
Thank you, Michael.

this looks like a big stumbling block for me. I do .NET since 2002, yet it
is my only language so I don't have any C/C++/Win32 knowledge. Is there an
intro article about memory mapped files?

I did other operating systems before where data structures could be compiled
into .dlls, loaded into memory and accessed by all apps which were linked
against this .dll

Basically my IO apps read hundreds of relais, opto couplers and the like and
need to offer this knowledge to other apps which draw conclusions, do
emergency halts, and some other serious stuff.

I do not want to send all the data to all the possible recipients using
network protocols, and I do not want to duplicate data inside a single
computer.

It also needs remote events from server to clients, which I do using .NET
remoting while waiting for Indigo to pass the bleeding edge. (aka books and
samples about WCF).

best regards herbert
Nov 26 '06 #3
Hello herbert,

hthis looks like a big stumbling block for me. I do .NET since 2002,
hyet it is my only language so I don't have any C/C++/Win32 knowledge.
hIs there an intro article about memory mapped files?

See the MSDN for more details about MMF

So, probably you need Singleton class
hI do not want to send all the data to all the possible recipients
husing network protocols, and I do not want to duplicate data inside a
hsingle computer.

How are u going to communicate with you class if u don't want to send data
to recipients?

hIt also needs remote events from server to clients, which I do using
h.NET remoting while waiting for Indigo to pass the bleeding edge.
h(aka books and samples about WCF).
Thus just create Singleton service which will maintain your shared data and
choose appropriate IPC way for communications

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 26 '06 #4
Its not too hard there are lots of examples around. Sharing data
amongst many applications via shared memory is reasonably common thing
to do. The way we did it was to have a dll written in unmanaged C++.
With .Net 2.0 it was real easy to use the dll in managed C++. In our
case .Net is only one development environment to use the shared memory.
We also use VB6, C++, Labview, and Java. Our shared memory can also be
shared to other machines so applications can be distributed. It uses an
replication scheme to manage this. Bottom line is though you will
probably have to learn C++ and Win32 APIs to do this. The really hard
part though is doing things in a very concurrency safe scheme. Unless
you are really familiar with Mutexes and NT events you might have a very
difficult time to get it safe. Also creating a shared memory manager
with compaction is also tricky especially if any of your applications
are soft real time like ours. I have a solid code base for dealing with
all this and would live to open source it but can't because i used
company tools to make it. Someday i will start from scratch on my own
machine on my own time to create a new code base so i can open source
it. That may be a while though.

Hope this helps
Leon Lambert

Michael Nemtsev wrote:
Hello herbert,

hThe apps need to share a common memory as there are lots of variables
hto be shared (and synchronized of course).

Shared among who? How much your app is distributed?
For example you can use MMF
http://groups.google.com/groups/sear...y+mapped+file&
but I'm not sure that is the right thing for u

hI need distinct apps for reasons like user interaction/access rights,
herror compartments, and because the size of the code, access to various
hports, ...

So, u need the set of control services? how shared memory will help u here?

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Nov 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with...
3
by: alanrn | last post by:
I would like to start a dialog on how to implement the equivalent functionality of UNIX shared memory in .NET. I work with a factory automation system. The bulk of the system is written in C/C++....
5
by: Bernard | last post by:
Hi, Is there a way to have the virtual table of c++ objects allocated in shared memory (in fact in the same address space as the object is) instead of having it allocated in the process address...
12
by: Jeremy | last post by:
Hi all, I'm getting very confused about how DB2 uses shared memory and I wonder if someone could clarify matters for me, please ? We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine...
96
by: BadPony | last post by:
Anyone using Peoplesoft on a Federated UDB (shared nothing)Environment on Open System Platforms? Preferably AIX, but any war stories would be good. TEA EB-C
3
by: Grandpa Pete | last post by:
How can I share resources across all users of a web service for read/write access. *Situation* *one*: I want to have an in memory counter that all users of the webservice could access. Call...
2
by: david.sanderson | last post by:
Hi, Hopefully this is thecorrect group, its a bit C++ and a bit POSIX... Ive had a look in the archives, and Im a bit confused.... I have some classes in a shared library (a .so on a QNX...
10
by: Oriane | last post by:
Hello, I have to share a object in RAM between several processes. I intend to design a special process to load this objet (an Autocad plan) in memory, and to take care of the read/write...
11
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global"...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.