Definition
Scheduling
Scheduling is the process by which an operating system determines the order in which processes are executed on the processor. The goal is to optimise system performance according to various criteria.
Tasks and Objectives
The primary task of scheduling is to manage the competition for CPU time among active processes. Key optimisation goals include:
- Throughput: Maximising the number of processes completed per unit of time.
- Processor Utilisation: Keeping the CPU as busy as possible.
- Fairness: Ensuring that every process receives a reasonable share of processor time without starvation.
- Response Time: Minimising the time between a user request and the first response (critical for interactive systems).
- Turnaround Time: Minimising the total time from process submission to completion.
- Deadlines: Ensuring that critical tasks complete within their specified time constraints (see Real-Time Scheduling).
Selection Function and Decision Mode
A scheduling strategy is defined by two main components:
- Selection Function: The logic used to choose the next process from the Ready Queue (e.g., based on priority, execution time, or wait time).
- Decision Mode: Specifies when the selection function is invoked.
- Non-preemptive: A process continues to run until it terminates or blocks itself (e.g., for I/O).
- Preemptive: The OS can interrupt a running process to allocate the CPU to another process (e.g., due to a clock interrupt or a higher-priority process becoming ready).
Activation of the Scheduler
The short-term scheduler (or dispatcher) is typically activated by the following events:
- System Calls and Traps.
- I/O Interrupts or signals.
- Clock Interrupts (for time-slicing).