When a computer is multi-programmed, it has many processes competing for CPU at a time. This situation occurs when two or more processes are simultaneously in the ready state. Key issue related to scheduling in which when to execute that process that means OS has to make decision there are some criteria’s based on which process is picked for execution from ready queue. Let’s take example of one situation where process is waiting for I/O interrupt to occur a scheduling decision may make. If interrupt come from I/O some process that was blocked for I/O may now ready to run.
Now we will discuss some important scheduling algorithms
First Come First Serve
This is very simple kind of Scheduling algorithm. Basically there is one ready queue maintained by operating system. When OS picks one process to execute it runs till its burst time. If any another process comes it is placed at the tail of ready queue. One advantage of this algorithm is it is very easy to understand and implement. Real example of this algorithm would be people standing in admission queue. One biggest disadvantage of FCFS is it does not treat all processes equally, suppose there are 2 processes one is at head of ready queue having burst time 1 ms and another having burst time 1000 MS which is at tail of ready queue in this case OS will execute first process.
Shortest job first(SJF)
As stated earlier FCFS suffers from one problem it doest not treat all processes treat equally. To overcome this problem SJF has been introduced. There are two variations of SJF one is Non-Preemptive SJF and Preemptive SJF. In Non-Preemptive SJF process having shortest bust time is selected first for execution. If tow processes have same burst time then they are selected according to their arrival time. Once process is assigned to CPU it runs as long as its burst time and while execution if new process comes having shortest bust time running process is not preempted. Preemptive SJF is similar to Non-Preemptive SJF except one difference. When new process comes having burst time less than running process then in Preemptive SJF currently running process is preempted.
Round Robin Scheduling makes ascension that all processes are equally important. The basic concept behind is to assign priority to each process. Process having height priority is assign to CPU first. Priorities can be assigned to processes either statically or dynamically. In windows XP user can change the priority of process from task manager.
Round Robin Scheduling
The basic concept behind round robin scheduling is all processes are maintained in a circular queue. Each processes is assigned a time slice also called as time quantum which it is allowed run process is still running after finishing its time slice then process is preempted and next process is selected for execution. Round robin is easy to implement. If the time slice is set longer than mean CPU burst then preemption will happen really and this should not happen.