This Java program simulates different schedulers. It provides simulations for the following schedulers:
- Preemptive Shortest-Job First (SJF) Scheduling with context switching.
- Round Robin (RR) with context switching.
- Preemptive Priority Scheduling with the solution to the starvation problem.
-
AG Scheduling:
- Each process is provided with a static time to execute called quantum.
- Once a process is executed for the given time period, it is treated as FCFS (First-Come, First-Served) until it finishes ceil(52%) of its quantum time. Then it is converted to non-preemptive Priority until it finishes the next ceil(52%) of its quantum time. After that, it is converted to preemptive Shortest-Job First (SJF).
-
There are 3 scenarios for the running process:
- The running process used all its quantum time and still has more job to do. In this case, the process is added to the end of the queue, and its quantum time is increased by two.
- The running process was executed as non-preemptive Priority and did not use all its quantum time because another process was converted from ready to running. In this case, the process is added to the end of the queue, and its quantum time is increased by ceil(the remaining quantum time/2).
- The running process was executed as preemptive Shortest-Job First (SJF) and did not use all its quantum time because another process was converted from ready to running. In this case, the process is added to the end of the queue, and its quantum time is increased by the remaining quantum time.
- The running process did not use all of its quantum time because it no longer needs that time and the job was completed. In this case, the process's quantum time is set to zero.
The program expects the following input:
- Number of processes
- Round robin time quantum
- Context switching
For each process, the following parameters are required:
- Process Name
- Process Arrival Time
- Process Burst Time
- Process Priority
For each scheduler, the program outputs the following:
- Processes execution order
- Waiting time for each process
- Turnaround time for each process
- Average waiting time
- Average turnaround time
- All history updates of quantum time for each process (AG Scheduling)