CPU Scheduling
CPU Scheduling is a fundamental function of an operating system that decides which process or programs get to run on the CPU and in what order. There are two most important type of CPU Scheduling are as given below.
| Note: It helps to manage the execution of multiple tasks on a computer. |
Types of CPU Scheduling
There are two most important types of CPU Scheduling, are as given below.
i) Pre-Emptive Scheduling
ii) Non Pre-Emptive Scheduling
1. Pre-Emptive Scheduling
In Pre-emptive Scheduling if a process enters the ready state and it is high priority process the current process can be interrupted and the CPU can be given to the high priority process. A process can also switches from running state to ready state because its time to quantum expire. There are four most important types of pre-emptive scheduling are given below.

Types of Pre-Emptive Scheduling
There are four most important types of Pre-Emptive Scheduling as given below.
i) Priority Scheduling
ii) Shortest Remaining Job First
iii) Longest Remaining Job First
iv) Round Robin
1. Priority Scheduling
In Priority Scheduling, a priority is associated with each process and the CPU is allocated to the process with the highest priority. It means that every process has a one priority. CPU is given the process which is highest priority. If both processes are priority are equal then the process that arrives first gets the CPU firsts ((FCFS).
2. Shortest Remaining Job First
Shortest Remaining Job First is also called Shortest Remaining Time First. In Shortest Remaining Job First if a new process arrives with a shorter CPU burst time than the remaining time of the currently running process, the CPU switches to the new process.
3. Longest Remaining Job First
Longest Remaining Job First is also called Longest Remaining Time First. It is a type of priority scheduling. In this method, the CPU is assigned to available process that has longest remaining execution time. If another process has a longer remaining time, the CPU can switch to that process.
4. Round Robin
Round Robin is an important type of preemptive CPU scheduling. It is also designed for time sharing system, where each process gets fixed amount of CPU time. If a process is not completed within this time, the CPU switches to the next process.
2. Non Pre-Emptive Scheduling
In Non Pre-emptive Scheduling when a process completes its execution, it leaves the CPU. A process can also leave the CPU voluntarily to perform some I\O operation or to wait for an event. There are four most important types of pre-emptive scheduling are given below.

Types of Non Pre-Emptive Scheduling
There are four most important types of Non Pre-Emptive Scheduling as given below.
i) First Come First Serve
ii) Shortest Job First
iii) Longest Job First
iv) Highest Ratio Response Next
1. First Come First Serve
FCFS stand for First Come First Serve. In this method, simplest scheduling algorithm assign CPU to the process which arrive first. It means that it is the simplest CPU scheduling algorithm. It can be easily understand and can easily be implemented using the data structure. FCFS always the non preemptive nature.
2. Shortest Job First
SJF stand for Shortest Job First. In this method, out of all available process CPU is assigned to the process having burst time requirements. It means that it does not depend on the priority or seniority. If two processes have the same burst time, FCFS is used to break the tie.
3. Longest Job First
LJF stand for Longest Job First. LJF can be used in both preemptive and non preemptive scheduling. In longest job first CPU is assign to the process having largest burst time among all the available process. If two processes have the same burst time, FCFS is used to break the tie.
4. Highest Ratio Response Next
HRRN stand for Highest Ratio Response Next. In this method scheduling is a non preemptive discipline, similar to shortest job next (SJN) in which priority of each job is dependent on its estimated run time, and also the amount of time it has spent waiting. It means that CPU runs the process with the highest ratio first.
Formula:
