Process Scheduling and Policies Explained
Process Scheduling and Policies Explained
SJF minimizes response time by selecting the shortest jobs first, ensuring that small jobs are completed quickly. This method requires clairvoyance or user input to estimate job lengths, which makes it difficult to implement accurately. A significant drawback of SJF is the potential for starvation, where continuous short jobs can indefinitely delay longer processes from executing .
In Round Robin scheduling, the quantum is the fixed time period allotted for each process to execute before switching to the next. Selecting the right quantum size critically affects system performance; a larger quantum may lead to longer waiting times and reduced system responsiveness, nearing First-Come-First-Served behavior, while a smaller quantum enhances responsiveness but can increase context-switching overhead, reducing throughput. Therefore, a balanced quantum ensures responsiveness without compromising efficiency, typically by ensuring context switch overhead stays below 1% .
MLF uses multiple priority levels for processes, applying round-robin scheduling within each level but allowing quantum sizes to decrease with priority level. This strategy adapts to varying process requirements and demotes jobs to lower priority levels if they don't complete within the designated quantum. The main advantage of MLF is its flexibility in providing dynamic adjustments to process scheduling, balancing between responsiveness and throughput .
Preemptive scheduling optimizes process management by allowing the CPU to switch between processes in response to external events, reducing idle time and enhancing responsiveness. It supports efficient time-sharing systems and multitasking. However, this approach introduces challenges such as increased complexity in process management, requiring sophisticated algorithms and hardware features like timer interrupts, which can complicate system design and increase overhead .
Non-preemptive scheduling allows a process to occupy the CPU until it finishes or blocks, offering simplicity but leading to potential issues like long waiting times for other processes. Examples include First-Come-First-Served (FCFS), Shortest Job First (SJF), and Priority Scheduling (PS). Preemptive scheduling involves switching processes between running and ready states, which allows for better efficiency and capabilities but requires more complex mechanisms and hardware support such as timer interrupts. Examples include Round Robin (RR), Shortest Remaining Time First (SRTF), and Multi-level Feedback Queue (MLF).
Process state transitions occur between the states of Ready, Running, and Waiting. Transitions are triggered by specific conditions: a process moves from running to waiting due to its action, non-preemptive scheduling; from running to ready due to external events, preemptive scheduling; from waiting to ready once resources are available; and finally, from running to terminated when the process completes its execution .
The scheduling discipline significantly affects CPU and device utilization, influencing overall system efficiency. Disciplines like FCFS can lead to poor overlap of I/O and CPU processing, causing devices to remain idle while CPU-bound processes execute. Performance metrics commonly used to assess scheduling include CPU/device utilization rates, system throughput, waiting time, and response time, each reflecting different aspects of scheduler efficiency and system performance .
Estimating execution time is crucial in SJF scheduling because it determines job ordering to minimize response time. An effective method for estimation is using historical data, where the predicted length of the next CPU burst is calculated using prior burst durations. The formula tn+1 = αtn + (1–α)tn for 0 ≤ α ≤ 1 leverages the principle that recent history can indicate near-future performance .
Round Robin scheduling assigns each process a fixed time quantum within which it can run, after which the next ready process is scheduled. Selecting a time quantum involves trade-offs: a large quantum increases waiting time and can resemble FCFS, whereas a small quantum improves responsiveness but decreases throughput due to increased context switch overhead. The goal is to balance these factors to keep context switch overhead below 1% .
Aging is a technique used in Priority Scheduling systems to prevent starvation by gradually increasing a process's priority over time. This is done by decreasing the numerical priority value, which eventually makes lower-priority processes more competitive and ensures they eventually receive CPU time, thus enhancing fairness in the scheduling system .