Preemptive scheduling provides a mechanism for ensuring that the system is always performing its most important task. A preemptive scheduling algorithm will give priority to the most important task, regardless of what else in the system is happening – except for interrupts, since they occur underneath the scheduler and always have a higher priority. This sounds very straightforward – and it is – except that there are some details that need to be taken into consideration.
Let's take a look at the same three tasks. These three tasks all have the same functionality: a simple while loop that endlessly increments a volatile variable.
Now, consider the following three scenarios to figure out which of the three tasks ...