Embedded Systems & Firmware
In a preemptive RTOS, while a low-priority task is running, a high-priority task receives the data it was waiting for and becomes ready. What generally happens?
- AThe high-priority task waits until the low-priority task finishes on its own
- BBoth tasks stop and the microcontroller reboots
- CThe low-priority task is suspended midway and the high-priority task runs immediately
Show answer and explanation
Answer: C. The low-priority task is suspended midway and the high-priority task runs immediately
In a preemptive RTOS, when an interrupt or similar event makes a higher-priority task ready, the kernel saves and suspends the running low-priority task and switches to the high-priority one. When the high-priority task finishes or blocks, the low-priority task resumes where it left off. This keeps response times for high-priority work short and predictable.
- A. That is cooperative (non-preemptive) switching.
- B. There is no reboot.
- C. Correct. This is preemption.