CPU scheduling
Scheduling of process is done to finish the work on time. CPU scheduling is a process that allows one process to use the CPU while another process is delayed due to the unavailability of resources. The purpose of CPU scheduling is to make the system more efficient, faster, and fairer.
CPU scheduling algorithm
CPU scheduling is the process of deciding which process will own the CPU to use while the other process is suspended. The main function of CPU scheduling is to ensure that whenever the CPU remains idle, the OS must have at least one process available in the ready-to-use line.
Terminologies:
- Arrival Time: The time at which the process arrives in the ready queue.
- Completion Time: The time at which the process completes its execution.
- Burst Time: Time required by a process for CPU execution.
- Turn Around Time: Time Difference between completion time and arrival time.
There are mainly two types of scheduling methods:
- Preemptive Scheduling: Preemptive scheduling is used when a process switches from the running state to the ready state or from the waiting state to the ready state.
- Non-Preemptive Scheduling: Non-Preemptive scheduling is used when a process terminates, or when a process switches from a running state to waiting state.
1. First Come First Serve:
FCFS considered being the simplest of all operating system scheduling algorithms. The first come first serve scheduling algorithm states that the process that requests the CPU first is allocated the CPU first and is implemented by using a FIFO queue.
- FCFS supports non-preemptive and preemptive CPU scheduling algorithms.
- Tasks are always executed on a First-come, First-serve concept.
- FCFS is easy to implement and use.
- This algorithm is not much efficient in performance, and the wait time is quite high.
- Easy to implement
- The first come, first serve method
- FCFS suffers from the Convoy effect.
- The average waiting time is much higher than the other algorithms.
- FCFS is very simple and easy to implement and hence not much efficient.
2. Round robin:
Round Robin is a CPU scheduling algorithm where each process is cyclically assigned a fixed time slot. It is the preemptive version of the First Come First Serve CPU Scheduling algorithm. Round Robin CPU Algorithm generally focuses on Time Sharing technique.
Characteristics of Round robin:
- It’s simple, easy to use, and starvation-free as all processes get the balanced CPU allocation.
- One of the most widely used methods in CPU scheduling is a core.
- It is considered preemptive as the processes are given to the CPU for a very limited time.
- Round robin seems to be fair as every process gets an equal share of CPU.
- The newly created process is added to the end of the ready queue.