Different processes and threads need to exchange data among them. The control system together with the safety system is executed by different threads in the same process. The simulator and various services run in their own processes to acquire signal information during runtime such as scopes.
Sharing data in EEROS is mainly used to transport signals among threads and processes. Signals can be written by a single writer, as there is always just one source for any signal. On the receiving end many readers might read the signal. The signal itself consists of all the necessary data which describe its properties, e.g. value, unit, time stamp.
Each signal buffer has a single writer but can have many readers. Reading is done with a check-after-read procedure. This prevents a writer having to wait for a reader. After each read the reader checks if the data was changed in the mean time, and if that is the case the data will be read again.
Each signal buffer uses a ring buffer and a header, so an object of type
signalBuffer has the following layout:
When such an object is created the user has to pre-allocate memory for this structure. This can be done on the heap (if sharing of signal data is between threads running in the same process) or in shared memory (if different processes are involved).
// allocating memory on heap void* memory = malloc(MEM_SIZE); // allocating memory in shared segment SharedMemory* shm = new SharedMemory("/eeros.shm", MEM_SIZE); void* memory = shm->getMemoryPointer(); // using this memory for signal buffer SignalBuffer sb(memory, 1024);
For debugging purposes the following commands deal with shared memory segments under Linux:
ipcs : List all shared memories ipcrm -M 0x010165f9 : Removes the shared memory with the given key
External processes should be able to do the following things: