Emesary implementation of a message based real time systemEmesary implementation of a message based real time system admin 11 July, 2009 - 18:28
This entire entry is really a set of notes to remind me of an idea I've just had....
There are many ways of implementing an real time executive, i.e. a system that takes responsibility for loading, running, and monitoring individual sections of code.
Sitting here just now looking at some code related to the simulation of an aircraft, specifically the equations of motion, aerodynamics, engines and navigation systems, it occurred to me that there may be a better way of putting together the essential areas, namely
- module initialisation execution and scheduling
- shared data
- private data
- Interprocess Communications
The basic idea, and it is just an idea at the moment, is to try to do this using something similar to my favoured approach for many things (Emesary).
Providing that the modules are registered on the event notification bus in the correct order, then effectively the scheduler and notification can become one procedure. We have one message that is passed around to all modules at 30hz (or whatever required rate). This message is effectively the shared and private data, maybe with some conventions attached. Each module that receives the message performs its required processes, and finishes, whereby the message continues to the next process.
Areas that initially cause me concern are performance and multi threads/processors/systems.
Performance concerns can be easily addressed by simply containing datapool within the message, and passing the message by reference or by handle.
However, I'm falling back on to tried and trusted methods for the multi-threaded approach, and these don't necessarily sit well in the object world, so this needs thoughts. Initially I'm thinking of using something akin to strict value level security to define the write access to each data item, but this is going to make things slower, although maybe it would also gain benefit by allowing event generation (eg. exceptions) based on data item modification. That way the owning module, or RT-exec, could at least know about overwrites, or modules attempting to modify stuff that they simply don't own.
Also, if this works well for a real time system, then maybe it can be used to take advantage of multithreading in traditional systems, needs more thought.