Operating Systems: Non-preemptive scheduling algorithms
An operating system manages computer hardware and software resources and controls the flow of processes in the central processing unit through a process called scheduling. Essentially, an OS schedules processes to be executed in the CPU and allows for seamless execution of multiple programs. There are different ways an operating system schedules processess in the CPU and one of them is non-preemptive scheduling. In this type of scheduling, the operating system lets one process run to completion in the CPU without any interruptions before allowing another process to be executed. The three types of non-preemptive scheduling algorithm are: First Come First Serve (FCFS), Shortest Job First (SJF), and Priority Scheduling.
- FCFS executes processes in order of their arrival times into the ready queue. The first process to arrive gets scheduled to cpu and executed first.
- In SJF, the process with the shortest burst time(time it takes a processes to run in CPU) gets executed first. This algorithm penalizes processes with long executing times since they are given a lower priority during scheduling.
- Priority scheduling follows a ranking system where each process is assigned a priority value. Higher priority processes get executed first. As a result, lower priority processes are penalized and likely to “starve” i.e. they may fail to execute if higher priority processes keep arriving into the ready queue.
Non-preemptive scheduling is an old scheduling technique as it comes with a few drawbacks. Since one process has to complete execution in the CPU before another process starts running, CPU utilization is less efficient and thus, the waiting time and response time of processes is higher. Preemptive scheduling is another type of scheduling that allows processes to be interrupted based on a number of rules. Check out more about preemptive scheduling in my next blog.