CPU scheduling is the process of interchanging between executing processes, which serves as the foundation of multiprogrammed systems. This transition guarantees that the computer's CPU usage is optimized, resulting in higher productivity.
Non-preemptive scheduling is a scheduling algorithm that does not allow a process to be interrupted by another process of higher priority. This means that once a process is running, it will not be interrupted until it is finished or blocked.
Preemptive scheduling is a scheduling algorithm that allows a process to be interrupted by another process of higher priority. This means that once a process is running, it may be interrupted until it is finished or blocked.
FCFS is a non-preemptive scheduling algorithm that executes processes in the order in which they arrive in the ready queue. The waiting time for each process is simply the sum of the burst times of all processes that arrived before it. FCFS is simple and easy to implement, but it can lead to long waiting times if a process with a long burst time arrives early in the ready queue.
SJF is a non-preemptive scheduling algorithm that executes the process with the shortest burst time first. This algorithm provides the minimum average waiting time for a given set of processes. However, it requires knowledge of the burst times of all processes in advance, which is often not available in real-world scenarios.
Priority scheduling is a scheduling algorithm that assigns a priority to each process and executes the process with the highest priority first. This algorithm can be either preemptive or non-preemptive. In the preemptive version, a running process can be interrupted by a higher priority process, while in the non-preemptive version, a running process will not be interrupted. Priority scheduling can lead to starvation if a low-priority process never gets a chance to run.
Round Robin is a preemptive scheduling algorithm that assigns a time quantum to each process. Each process is executed for a time quantum and then is moved to the end of the ready queue. This algorithm provides a fair chance to each process and prevents starvation. It also minimizes the average waiting time for each process. However, it may lead to a longer average waiting time than FCFS.