As tasks are executing on a CPU, when there are several tasks to choose from (ready for execution),it must be decided which task to execute. Tasks can have different priorities in order to, for example,let a more important task execute before a less important task.
Moreover, an RTS can be preemptive or nonpreemptive.
In a preemptive system, tasks can preempt each other, allowing for the task withthe highest priority to execute as soon as possible.
However, in a nonpreemptive system a task thathas been allowed to start will always execute until its completion, thus deferring execution of any higher priority tasks.
The difference between preemptive and nonpreemptive execution in a priority scheduled system is shown in Figure .. Here, two tasks, task A and task B, are executing on a CPU.