Some developers call Preemption to the ability of a processor to interrupt a task (or interrupt) when a higher interrupt occurs.

If a low priority task is not to be preempted, then the higher priority interrupt must wait until this task finished. The following diagrams shows what happens when a task is NOT preemptive.

The data of the task is cleared when the task ends, and the data of the interrupt is not being accumulated with the data of the task, as the diagram shows:

If a low priority task is to be preempted, then the higher priority interrupt will enter immediately making the task do several backups of temporal data and the address of the unfinished operation beginning in the stack. The following diagram shows what happens when a task is preemptive.

Of course, the data of the task is saved in the stack (Register + Program Counter Address (PC)) before the interrupt is detected, when the interrupt is detected, its temporal data is piled up in the stack as the following image shows:

If there is a high priority interrupt running, then all the low priority interrupt will wait to be dispatched.

That’s it for now!

Leave a Reply

Your email address will not be published.