Skip to main content

Process Scheduling

Process Scheduling is a critical component of process management that is handled by the kernel in an operating system.

Process scheduling plays a crucial role in ensuring that all processes get their fair share of CPU time and resources, which helps in achieving maximum efficiency and performance of the system.

Goals of Process Scheduling​

The main objectives of process scheduling are to enhance system performance, ensure fairness among processes, and meet the specific requirements of the operating system. Here's a breakdown of these goals:

  • Maximize CPU Utilization: Ensure that the CPU is kept as active as possible to avoid idle time and maximize productivity.

  • Maximize Throughput: Increase the number of processes that complete execution in a given amount of time.

  • Minimize Turnaround Time: Reduce the total time taken from when a process is submitted until it is completed.

  • Minimize Waiting Time: Decrease the amount of time a process spends in the ready queue waiting to be executed.

  • Minimize Response Time: Shorten the time from when a process is first submitted to when it receives its first response or starts executing.

  • Fairness: Guarantee that all processes receive a fair share of CPU time and resources, avoiding favoritism.

  • Meet Deadlines: Particularly crucial in real-time systems where certain tasks must be completed within predefined time constraints.

  • Avoid Starvation: Ensure that no process is indefinitely deprived of the CPU time or resources it needs to execute.

  • Maintain System Stability: Prevent system overloads and ensure that the operating system remains responsive and stable under various loads.

Preemptive Scheduling​

In preemptive scheduling, the operating system can interrupt and suspend a currently running process to start or resume another process.

Advantages​

  • Improves Responsiveness: This is particularly beneficial for real-time and interactive applications where quick responses are crucial.

  • Better Utilization of CPU: By allowing the CPU to switch to ready processes when the current process is waiting for I/O, preemptive scheduling keeps the CPU busy.

  • Prevents Long Wait Times: By preventing any single process from monopolizing the CPU, it helps to reduce both turnaround and waiting times for other processes.

Disadvantages​

  • Overhead: Frequent context switching can lead to increased overhead, slightly reducing overall system performance.

  • Complexity: Implementing preemptive scheduling is more complicated due to the need to manage interrupts and multiple process states effectively.

Common Algorithms​

  • Round Robin: Processes are assigned a fixed time slice and are executed in a cyclic order, promoting time sharing.

  • Preemptive Priority Scheduling: Processes with higher priority can preempt those with lower priority.

  • Shortest Remaining Time First (SRTF): The running process is preempted if a new process arrives with a shorter remaining execution time.

Non-Preemptive Scheduling​

In non-preemptive scheduling, a process running on the CPU continues to execute until it either completes its execution or initiates an I/O operation and enters a waiting state.

Advantages​

  • Lower Overhead: Fewer context switches mean less CPU time is spent on managing process transitions.

  • Predictable: Easier to predict how processes will behave, as they run to completion once started.

  • Simple Implementation: Non-preemptive scheduling is simpler to design and implement.

Disadvantages​

  • Poor Responsiveness: Long-running processes can delay the execution of other processes, especially those that are more interactive or time-sensitive.

  • Possible Starvation: Processes with lower priority may starve if higher-priority processes continue to arrive.

  • Inefficient CPU Utilization: The CPU may become idle if the current process is waiting for I/O, leading to inefficiencies.

Common Algorithms​

  • First-Come, First-Served (FCFS): Processes are executed in the order they arrive, without preemption.

  • Shortest Job Next (SJN): Executes the process with the shortest execution time next, reducing average turnaround time.

  • Priority Scheduling (without preemption): Processes are executed based on priority, but without preemption, meaning the process will continue until it finishes or blocks itself.