Glossary · Automation software engineering and architecture
Shared memory
German: Gemeinsamer Speicher
In computing, shared memory is a memory area accessible to several processes, threads or processors, used to exchange data quickly without copying it through messages.
- Software engineering
In one sentence
Shared memory is a memory area several processes, threads or processors can access to exchange data quickly without messages.
Example
The soft PLC and the vision application on the same industrial PC exchange inspection results through a shared memory area synchronized with a semaphore.
How it applies
- Engineering: Shared memory is the fastest way to exchange data locally but offers no built-in synchronization. Access must be coordinated with locks, lock-free structures or a clear single-writer rule.
- Robustness: A faulty process can corrupt data in shared memory for all others. Data should carry validity information, such as sequence counters or checksums.
- Documentation: For interfaces based on shared memory, document the memory layout, data types and byte order, update rate and the synchronization protocol. Layout changes are breaking changes.
Shared memory vs. message passing
With shared memory, parties read and write the same data. With message passing, such as a Message queue, each party has its own copy and data is exchanged explicitly, which is easier to get right and works across computers.