AG Scheduling (Adaptive General Scheduling) is a CPU scheduling algorithm that dynamically combines FCFS, Priority, and Shortest Job First (SJF) based on the execution phase of each process.
Each process is assigned a static time slice called Quantum.
The execution of a process is divided into three phases:
- FCFS Phase – Non-preemptive execution for a fraction of its quantum.
- Priority Phase – Preemptive execution based on priority for the next fraction of its quantum.
- SJF Phase – Preemptive execution based on remaining burst time for the rest of its quantum.
-
Quantum Usage:
- The process runs according to its current phase (FCFS → Priority → SJF).
- Quantum is updated based on whether the process completes or is preempted.
-
Scenarios:
Scenario 1: The running process used all its quantum and still has remaining burst:
- Move to end of ready queue.
- Increase quantum by 2.
Scenario 2: Process executed during Priority phase and was preempted:
- Move to end of ready queue.
- Increase quantum by ceil(remainingQuantum / 2).
Scenario 3: Process executed during SJF phase and was preempted:
- Move to end of ready queue.
- Increase quantum by remaining quantum.
Scenario 4: Process completed before using all its quantum:
- Set quantum to 0.
