Training
×

Synchronization - thread priorities vs. IPC

If your system is time triggered, characterized by precise, periodic time intervals and you exactly know the execution time of your interlocked control loops, thread priorities provide managed execution of your application with minimal overhead. Solely relying on priorities requires a deep understanding of the time constraints. If parts of your application need more time to execute, the implicit, time-bound synchronization between time-critical loops may no longer work. Even working applications may fail on faster CPUs: if the loops are not connected to periodic time intervals but just start when the higher priority loop is done, the system may get out of sync by producing output too early.
If your system is event triggered,  characterized by external triggers that happen at an unpredictable time, an explicit synchronization using IPC to control data and control flow is recommended. IPC imposes some overhead, but you benefit from a system that easily scales and works through the different functions in a sequence that will not change, no matter how many nodes you use or how fast they are.