Shared Memory Pool

Hi, i am trying to find out how a Shared Memory Pool works.

1) A driver will be coded in C will read all the I/O values from a I/O device.
2) All the values will be placed in Memory.
3) Clients coded in VB.net will access the memory area, get the values and perform what they are supposed to do according to the value.

Is the above possible? If possible i need some ideas on the implementation because i am abit lost... But the above is from my understanding of what a shared Memory pool is and its uses... anyone with another understanding of a shared memory pool are welcome to comment...

Can any apps access any memory location?

thanks
jaxrpcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PockyMasterCommented:
I think the easiest solution would be:

let your c driver do the I/O stuff.
Create a c/c++ DLL to read the stuff from your memory and handle the management for your memory and link this to your VB.NET project.

According to my humble opinion, you cannot, or very hard, do it from VB.NET without the help of unmanaged code.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlexFMCommented:
Do you mean memory-mapped file?
In any case you need to write client code in C. Different drivers require different client code - using CreateFile or Setup SDK functions, ReadFile, WriteFile, DeviceIoControl etc. - this must be written in driver documentation. If you are working together with driver developer, he must know this.
C/C++ client talks with driver and reads values using functions like DeviceIoControl. Having these values C/C++ can make them available for VB clients. Placing variables to shared memory is possible, but this is not straightforward and requires adding PInvoke code to VB .NET client.
I think the best way is writing managed C++ wrapper which talks with driver and provides pure .NET interface for VB .NET clients.
0
farsightCommented:
I considered using a .NET Windows Service using remoting for communication.
But I think the C code in the driver to call using remoting would be very difficult.

So I think another means of communication would be better.

Here's a .NET Windows Service using an memory mapped file for the data and using a TCP network port for communication.

A .NET Memory-Mapped Cache TcpListener Service
http://www.eggheadcafe.com/articles/20050116.asp
It's not the best-organized piece of code, but looks workable.
I haven't looked into this in detail, but I think you could take the client code, put it in it's own DLL, and compile it with a COM-Compatible-Wrapper.  The COM DLL should then be callable from both the C driver and the .NET clients.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

farsightCommented:
It might be simpler to roll your own using these .NET wrappers for the .NET clients, and just use memory-mapped-file WIN32 API calls directly in the C driver.

simple library that wraps the Win32 Memory Mapped File services
http://www.winterdom.com/dev/dotnet/index.html
0
farsightCommented:
Also, here's tutorial on how to create a windows service and add TCP communications to it.
It's much simpler and clearer that the eggheadcafe example above.
http://www.aspfree.com/c/a/C-Sharp/Creating-a-Windows-Service-with-C-Sharp-introduction/

P.S. A windows service is basically just a program that starts at system startup, and remains running (unless intentionally shut down, or it fails).
0
farsightCommented:
I think I had some good suggestions, as did PockyMaster and AlexFM -- so I suggest splitting the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.