To understand the concept of preemptive and non preemptive scheduling, it is necessary to mention the circumstances under which CPU scheduling decisions may take place. These four circumstances are given below.
(1) When a process enter into waiting state from the running state.
(2) When a process enter into the ready state from the waiting state.
(3) When a process enter into the ready state from the running state.
(4) When a process terminates.
If we pay attention to these four circumstances then we come to the point that a new process have to execute as there are no chances of scheduling in circumstances one and four but there is choice of scheduling between circumstances two and three.
A scheduling scheme is known as non preemptive if it takes place under circumstances one and four and a scheduling scheme is known as preemptive, if it takes place under the circumstances 2 and 3. Solaris 2 and windows 2000 where both systems schedule threads using preemptive, priority based scheduling algorithms including supports for the real time threads.
Preemptive scheduling has a disadvantage. Suppose two processes are sharing data. One process is updating the data and it is preempted in the middle of its work and second process start. Second process tries to read the data which was being updated by process 1 but process 1 was preempted. It means that process 2 is trying to access the data which is in an inconsistent state.
(1) When a process enter into waiting state from the running state.
(2) When a process enter into the ready state from the waiting state.
(3) When a process enter into the ready state from the running state.
(4) When a process terminates.
If we pay attention to these four circumstances then we come to the point that a new process have to execute as there are no chances of scheduling in circumstances one and four but there is choice of scheduling between circumstances two and three.
A scheduling scheme is known as non preemptive if it takes place under circumstances one and four and a scheduling scheme is known as preemptive, if it takes place under the circumstances 2 and 3. Solaris 2 and windows 2000 where both systems schedule threads using preemptive, priority based scheduling algorithms including supports for the real time threads.
Preemptive scheduling has a disadvantage. Suppose two processes are sharing data. One process is updating the data and it is preempted in the middle of its work and second process start. Second process tries to read the data which was being updated by process 1 but process 1 was preempted. It means that process 2 is trying to access the data which is in an inconsistent state.