G
Guest
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++. It was
ported from UNIX to run under Windows using .NET. If for no other reason
than as an educational exercise, I have been wondering what it would take to
rewrite the system under C#.
The system currently has about a 100K “shared memory†segment. Under .NET
we are using memory mapped files. (I think that’s what they’re called!)
Using this, we get convenient and quick access to the data. Much of the data
is static, but a lot of it is dynamic. We have about a dozen core processes
running as services that continually access this data. Any process is
capable of both reading from and/or writing to the shared memory.
Using a very simplified example, we may have the following C structure:
struct
{
char name[9]; // station name
bool loadPresent; // is something currently at the station?
} STATION;
STATION stations[25]; // array of station information
STATION *gStations; // ptr to stations array.
STATION *myStation; // ptr to individual station
A station represents a location along a conveyor where a load may be.
In this simplified example, stations[] would be placed in shared memory.
When each process starts up, the value of gStations would be populated to
point to the beginning of stations[] in shared memory. A function would
exist that, given a station name, would find the appropriate station
information and return myStation as a pointer to that station’s information.
So, given the fact that multiple processes may need to read and update
information in the shared memory segment, what is the best way, under .NET,
to implement the same functionality? This information would be accessed on a
very frequent basis, so speed is critical.
One thought I’ve had is to have some type of server process act as the
guardian of this data. Though I don’t fully understand marshalling and
remoting under .NET, it appears that this is doable. I’m sure I could
eventually figure out the implementation details for this method, but I’m not
sure if it’s a good idea.
Any thoughts on this would be greatly appreciated.
..ARN.
functionality of UNIX shared memory in .NET. I work with a factory
automation system. The bulk of the system is written in C/C++. It was
ported from UNIX to run under Windows using .NET. If for no other reason
than as an educational exercise, I have been wondering what it would take to
rewrite the system under C#.
The system currently has about a 100K “shared memory†segment. Under .NET
we are using memory mapped files. (I think that’s what they’re called!)
Using this, we get convenient and quick access to the data. Much of the data
is static, but a lot of it is dynamic. We have about a dozen core processes
running as services that continually access this data. Any process is
capable of both reading from and/or writing to the shared memory.
Using a very simplified example, we may have the following C structure:
struct
{
char name[9]; // station name
bool loadPresent; // is something currently at the station?
} STATION;
STATION stations[25]; // array of station information
STATION *gStations; // ptr to stations array.
STATION *myStation; // ptr to individual station
A station represents a location along a conveyor where a load may be.
In this simplified example, stations[] would be placed in shared memory.
When each process starts up, the value of gStations would be populated to
point to the beginning of stations[] in shared memory. A function would
exist that, given a station name, would find the appropriate station
information and return myStation as a pointer to that station’s information.
So, given the fact that multiple processes may need to read and update
information in the shared memory segment, what is the best way, under .NET,
to implement the same functionality? This information would be accessed on a
very frequent basis, so speed is critical.
One thought I’ve had is to have some type of server process act as the
guardian of this data. Though I don’t fully understand marshalling and
remoting under .NET, it appears that this is doable. I’m sure I could
eventually figure out the implementation details for this method, but I’m not
sure if it’s a good idea.
Any thoughts on this would be greatly appreciated.
..ARN.