Preemptive and non preemptive scheduling .. Comparison between both - Cyber security & Technology

Breaking

Follow by Email

Wednesday, August 15, 2018

Preemptive and non preemptive scheduling .. Comparison between both








PREEMPTIVE & NON-PREEMPTIVE SCHEDULING


A scheduling algorithm can be preemptive or non-preemptive.

Non-preemptive scheduling

·        A scheduling discipline is non-preemptive if, once a process has been given the CPU, the CPU cannot be taken away from that process.

·        In other words, we can say in non-preemptive scheduling once the CPU has been allocated to a process, the process keeps the CPU until it release the CPU either by terminating or by switching to the waiting state

·        In non-preemptive systems, short jobs are made to wait by longer jobs, but the treatment of all processes is fairer

·        In such scheduling, response times are more predictable because incoming high priority jobs cannot displace waiting jobs.

·        Non-preemption scheduling method is used by Microsoft Windows 3.1 and by Apple Macintosh operating system.

Preemptive Scheduling

·        A scheduling discipline is preemptive if the CPU can be taken away from a process after being allocated .

·        In other words, even if the CPU has been allocated to a certain process, it can be snatched from this process any time either due to time constraint or due to priority reason.

·        In such a system, if a process with higher priority becomes ready for execution, the process which is currently using the CPU will be forced to give up the CPU so that higher priority job can run first.

·        Thus, preemptive scheduling is useful in systems in which high priority processes require rapid attention.

·        Preemptive scheduling is costly as compared to non-preemptive scheduling. switch also involves overhead in preemptive scheduling. For example, consider the case of two processes sharing data. One process may be in the midst of updating the data when second preempts it, then the second process might access the inconsistent data left in between by the first process. For coordinating access to the shared data, special mechanism must be provided by operating system and this is costly affair.

·        To make preemption effective, many processes must be kept in main storage so that the next process is normally ready for the CPU when it becomes available. Keeping non-running programs in main storage also involves overhead.

Comparison between preemptive and non preemptive scheduling

Preemptive
Non Preemptive
1.      A scheduling  discipline is preemptive if the CPU can be taken away from a process after being allocated.
A scheduling discipline is non preemptive if once a process has been given the CPU, the CPU cannot be taken away from that process.
2.      In other words, even if the CPU has been allocated to a certain process, it can be snatched from this process any time either due to time constraint or due to priority reason.
In other words, we can say in non preemptive scheduling once the CPU has been allocated to a process, the process keeps the CPU either by terminating or by switching to the waiting state.
3.      Preemptive scheduling is costly as compared to non preemptive scheduling. Context switch also involves overhead in preemptive scheduling.
Non preemptive scheduling is not costly as compared to preemptive scheduling.
4.      In preemptive systems, higher priority jobs are processed before the lower priority jobs.
In non preemptive systems, short jobs are made to wait by longer jobs.


No comments:

Post a Comment