Number of processes (1-32):
Enter name arrival burst priority for each process:
Round Robin time quantum:

=== FCFS ===
Gantt chart:
|       P1       |   P2   |        P3        |    P4    | P5 |
0                8       12                 21         26   28
Proc   Arrive Burst  Pri   Complete Turnaround Waiting Response
P1          0     8    3          8          8       0        0
P2          1     4    1         12         11       7        7
P3          2     9    4         21         19      10       10
P4          3     5    2         26         23      18       18
P5         20     2    1         28          8       6        6
Average waiting 8.20 | turnaround 13.80 | response 8.20

=== SJF (non-preemptive) ===
Gantt chart:
|       P1       |   P2   |    P4    |        P3        | P5 |
0                8       12         17                 26   28
Proc   Arrive Burst  Pri   Complete Turnaround Waiting Response
P1          0     8    3          8          8       0        0
P2          1     4    1         12         11       7        7
P3          2     9    4         26         24      15       15
P4          3     5    2         17         14       9        9
P5         20     2    1         28          8       6        6
Average waiting 7.40 | turnaround 13.00 | response 7.40

=== SRTF (preemptive SJF) ===
Gantt chart:
| P1 |   P2   |    P4    |      P1      |  P3  | P5 |     P3     |
0    1        5         10             17     20   22           28
Proc   Arrive Burst  Pri   Complete Turnaround Waiting Response
P1          0     8    3         17         17       9        0
P2          1     4    1          5          4       0        0
P3          2     9    4         28         26      17       15
P4          3     5    2         10          7       2        2
P5         20     2    1         22          2       0        0
Average waiting 5.60 | turnaround 11.20 | response 3.40

=== Priority (preemptive) ===
Gantt chart:
| P1 |   P2   |    P4    |      P1      |  P3  | P5 |     P3     |
0    1        5         10             17     20   22           28
Proc   Arrive Burst  Pri   Complete Turnaround Waiting Response
P1          0     8    3         17         17       9        0
P2          1     4    1          5          4       0        0
P3          2     9    4         28         26      17       15
P4          3     5    2         10          7       2        2
P5         20     2    1         22          2       0        0
Average waiting 5.60 | turnaround 11.20 | response 3.40

=== Round Robin ===
(quantum 3)
Gantt chart:
|  P1  |  P2  |  P3  |  P4  |  P1  | P2 |  P3  | P4 | P1 |  P3  | P5 |
0      3      6      9     12     15   16     19   21   23     26   28
Proc   Arrive Burst  Pri   Complete Turnaround Waiting Response
P1          0     8    3         23         23      15        0
P2          1     4    1         16         15      11        2
P3          2     9    4         26         24      15        4
P4          3     5    2         21         18      13        6
P5         20     2    1         28          8       6        6
Average waiting 12.00 | turnaround 17.60 | response 3.60

=== Comparison ===
Algorithm                Avg wait Avg turnar. Avg resp.
FCFS                         8.20       13.80      8.20
SJF (non-preemptive)         7.40       13.00      7.40
SRTF (preemptive SJF)        5.60       11.20      3.40
Priority (preemptive)        5.60       11.20      3.40
Round Robin                 12.00       17.60      3.60
Lowest average waiting time: SRTF (preemptive SJF)
