Glossary · Automation software engineering and architecture
Preemptive scheduling
Also known as: Preemptive multitasking
German: Präemptive Ablaufplanung
In operating systems, preemptive scheduling is a scheduling method in which the scheduler can interrupt a running task at any time to run a task of higher priority or when the running task's time slice expires.
- Software engineering
In one sentence
Preemptive scheduling lets the scheduler interrupt a running task at any time to run a higher-priority task.
Example
When the 1 ms motion task becomes ready, it preempts the 100 ms visualization task, which resumes after the motion task has finished.
How it applies
- Engineering: Preemption gives high-priority tasks short response times regardless of what lower-priority tasks do, which is why real-time systems and PLC runtimes with multiple tasks use it.
- Design: Any task can be interrupted between two instructions, so data shared between tasks needs protection, and priorities must be chosen with the timing analysis. Priority inversion must be addressed.
- Documentation: PLC manuals should explain the task model: which task types exist, their priorities and how preemption affects consistency of data between tasks. This is a common source of commissioning errors.
Preemptive vs. cooperative scheduling
In Cooperative scheduling, a task runs until it yields control voluntarily; one misbehaving task can block the others. Preemptive scheduling takes control away from tasks, which improves responsiveness but requires more care with shared data.