About Preemptive Type scheduling
On this page, we will learn the concepts of preemptive scheduling with the help of detailed explanation along with examples. Preemptive scheduling is a type of scheduling process which helps to schedule tasks with higher priority first and then the tasks with comparatively lower priority.
In an operating system (OS), a process scheduler performs scheduling of process. It includes switching of processes between the ready queue and waiting queue and allocating them to the CPU. The operating system assigns priority to each process and maintains these queues. The scheduler selects the process from the queue and loads it into memory for execution. This process scheduling takes place in two types: preemptive scheduling and non-preemptive scheduling.
In preemptive type of scheduling algorithm, a low priority process gets suspended from its execution, if a high priority process is waiting in the same queue for its execution. It is used when a process or task switches from running state to ready state or from waiting state to ready state. In this scheduling, the higher priority process is executed first.
At times, it is necessary to run a process that has a higher priority. If a high priority process arrives in the ready queue, it does not have to wait for the current process to complete its burst time. Instead, the running process is interrupted and is placed in the ready queue until the process with high priority is utilizing the CPU cycles. In this way, each process in the ready queue gets some time to run CPU.
Preemptive Scheduling ExampleP1 and P2 have different arrival times in the queue. Based on their priority or burst time, these processes are interrupted and allocated to the CPU. A process P1 arrives at time 0 and is allocated the CPU. Process P2 arrives at time 2, before P1 finishes execution. See the table below.
|Process||Arrival time||Burst time|
Types of Preemptive Scheduling algorithms
Shortest Job First (SJF) Scheduling
It is also called the Greedy In Preemptive Shortest Job First Scheduling, the processes are put into the ready queue as per their arrival time. When a process with the shortest burst time arrives, the existing process is removed from execution, and the process with the shortest burst time is executed first.
Round-Robin (RR) Scheduling
It is also called time-slicing scheduling. It is primarily designed for a time-sharing In Round-Robin (RR) Scheduling, the process is allocated to the CPU for the specific time period (time slice). If the process completes its execution within this time period, then it is removed from the queue or else it has to wait for another time slice.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment