written 3.6 years ago by |
Preemptive scheduling -
Preemptive scheduling as the name suggests is a scheduling process in which a currently running task is suspended in order to run a task that has a higher priority than it. Tasks are usually prioritized and their execution is carried out according to the priorities.The running task is interrupted for a brief period and later resumed once the priority task is executed.A scheduler that performs this function is called a Pre-emptive scheduler . The algorithm used by such schedulers to execute tasks is known as Pre-emptive scheduling algorithm.Two important approaches generally adopted in preemptive scheduling are time based preemption and priority based preemption. The various types of preemptive scheduling are:
- SJF(Shortest Job First) - In this type of Preemptive scheduling, the scheduler performs sorting and checks for the execution time of a task. If the execution time is less than the currently running one , it schedules the new task for execution. Preemptive SJF Scheduling is also known as Shortest Remaining Time(SRT) scheduling.
Round Robin Scheduling -In this type of scheduling, each task in the ready queue gets CPU time for a stipulated time-slot.The task is executed for a pre-defined interval and when the time period elapses, the next task is scheduled for execution.
diag. Round Robin Scheduling
Priority Based Scheduling - In this scheduling , any task having a high priority that enters the ready queue is immediately scheduled for execution. In functionality, it is similar to non-preemptive priority based scheduling except for task switching.
Non preemptive scheduling - Non preemptive implies that the processor is not pre-empted by any task and that the task that is currently running is allowed to continue until it has completed its service i.e the CPU dedicates its entire time in servicing that particular task and cannot be interrupted.The algorithm that is adopted by such a scheduler is known as Non preemptive scheduling algorithm.The different types of non-preemptive scheduling are:
- FIFO (First In First Out) - As the name suggests,the first task that is put in the ready queue is serviced first. This type of scheduling allocates CPU to tasks based on the order in which they enter the queue. However one drawback of this FIFO is that it monopolizes the tasks i.e if the task has any input/output operation ,the CPU is relinquished and if it does not have any input/output operation, its execution is continued until it is finished.
- LIFO (Last In First Out) - In this, the task that arrives last in the queue is serviced first. The algorithm allocates CPU time as per the order of arrival of the tasks.
- SJF (Shortest Job First) - In this, the task with the shortest estimated run time is selected first for execution, followed by next shortest estimated run time task and so on.A drawback of this scheduling type is that a job with high run time may not get sufficient CPU time as compared to tasks with lower run time.