User Tools

Site Tools


Sharing Data

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.

Signal Buffer

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.

Class diagram for SignalBuffer

Each signal buffer uses a ring buffer and a header, so an object of type signalBuffer has the following layout:

Each signal buffer uses a ring buffer and a header

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);

Shared Memory

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

Framework Integration

External processes should be able to do the following things:

  • Read any signal from the control part.
  • Write specified signals from the control part.
  • Read safety level.
  • Read actual sequences.
  • Send signals to the sequencer or safety system
for_developers/sharing_data.txt · Last modified: 2015/04/07 15:22 by