Glossary · Automation software engineering and architecture
Cooperative scheduling
Also known as: Cooperative multitasking, Non-preemptive scheduling
German: Kooperative Ablaufplanung
In operating systems and real-time software, cooperative scheduling is a scheduling approach in which a running task keeps the processor until it voluntarily yields, blocks or finishes, and the scheduler never interrupts it to run another task.
- Software engineering
In one sentence
In cooperative scheduling, a running task keeps the processor until it voluntarily yields; the scheduler never preempts it.
Example
A small embedded controller runs its tasks cooperatively; a new communication routine that forgot to yield during a long checksum calculation delayed all other tasks.
How it applies
- Engineering: Cooperative scheduling is simple and avoids many shared-data problems, because task switches only happen at known points. It is common in small embedded systems, event loops and coroutine-based frameworks.
- Risks: One task that runs too long or hangs blocks all others, so response times depend on the behavior of every task. A watchdog is needed to detect tasks that never yield.
- Documentation: Developer documentation should state the maximum allowed run time between yields and which functions may block. Without this rule, a single extension can break the timing of the whole system.
Cooperative vs. preemptive scheduling
In preemptive scheduling, such as Fixed-priority scheduling, the scheduler can interrupt a task to run a more urgent one, which gives predictable response times for high-priority tasks at the cost of more careful data protection. Cyclic PLC tasks are usually scheduled preemptively by priority; within a task, the program executes sequentially.