Glossary · Automation software engineering and architecture
Multithreading
Also known as: Multi-threading
German: Multithreading
In software engineering, multithreading is the execution of several threads within one process, sharing its memory, so that tasks can run concurrently or in parallel on multiple processor cores.
- Software engineering
In one sentence
Multithreading runs several threads within one process that share its memory, so tasks can run concurrently or in parallel.
Example
An HMI runtime uses one thread for screen rendering, one for communication with the PLC and one for alarm logging, so a slow network does not freeze the display.
How it applies
- Engineering: Threads share data, so access to shared variables needs synchronization, for example a Mutex or Semaphore. Missing synchronization causes a Race condition; wrong synchronization can cause deadlock or Starvation.
- Real-time systems: In a Real-time operating system (RTOS) threads or tasks get priorities, and timing analysis must include blocking and Priority inversion.
- Documentation: Architecture documents should show which threads exist, their priorities and which data they share. For users, document only what affects them, such as which settings change task timing.
Multithreading vs. multiprocessing
Threads share one address space and communicate cheaply through memory. Separate processes are isolated from each other and must exchange data through inter-process communication, which is safer but slower.